From 45ee39179665bf0d824ff1967645d2d98b697d87 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Fri, 8 Dec 2023 08:42:12 -0500 Subject: [PATCH] fix(duckdb): ensure that already quoted identifiers are not erased --- ibis/backends/base/sql/alchemy/__init__.py | 5 ++++- ibis/backends/base/sql/alchemy/query_builder.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ibis/backends/base/sql/alchemy/__init__.py b/ibis/backends/base/sql/alchemy/__init__.py index e69325fa5383..e43963c7595d 100644 --- a/ibis/backends/base/sql/alchemy/__init__.py +++ b/ibis/backends/base/sql/alchemy/__init__.py @@ -992,7 +992,10 @@ def _get_table_identifier(self, *, name, namespace): catalog=db, quoted=self.compiler.translator_class._quote_table_names, ).transform( - lambda node: node.__class__(this=node.this, quoted=True) + lambda node: node.__class__( + this=node.this, + quoted=node.quoted or self.compiler.translator_class._quote_table_names, + ) if isinstance(node, sg.exp.Identifier) else node ) diff --git a/ibis/backends/base/sql/alchemy/query_builder.py b/ibis/backends/base/sql/alchemy/query_builder.py index 28a863e715b9..5f9eb6c802c9 100644 --- a/ibis/backends/base/sql/alchemy/query_builder.py +++ b/ibis/backends/base/sql/alchemy/query_builder.py @@ -109,7 +109,10 @@ def _format_table(self, op): ) dialect = translator._dialect_name result.fullname = sg.table( - name, db=namespace.schema, catalog=namespace.database + name, + db=namespace.schema, + catalog=namespace.database, + quoted=translator._quote_table_names, ).sql(dialect=_SQLALCHEMY_TO_SQLGLOT_DIALECT.get(dialect, dialect)) elif isinstance(op, ops.SQLQueryResult): columns = translator._schema_to_sqlalchemy_columns(op.schema)