Skip to content

Commit b663f8e

Browse files
committed
remove quoting of db/table names in output
1 parent eeee1c6 commit b663f8e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/mimic_utils/transpile.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import sqlglot.dialects.bigquery
77
import sqlglot.dialects.duckdb
88
import sqlglot.dialects.postgres
9-
from sqlglot import exp, select, alias
10-
from sqlglot.expressions import Array, array
9+
from sqlglot import exp
10+
from sqlglot.expressions import to_identifier
1111

1212
# Apply transformation monkey patches
1313
# these modules are imported for their side effects
@@ -38,6 +38,16 @@ def transpile_query(query: str, source_dialect: str="bigquery", destination_dial
3838
for table in sql_parsed.find_all(exp.Table):
3939
if table.catalog == catalog_to_remove:
4040
table.args['catalog'] = None
41+
# we remove quoting of the table identifiers, for consistency
42+
# with previously generated code
43+
table.args['this'] = to_identifier(
44+
name=table.args['this'].this,
45+
quoted=False,
46+
)
47+
table.args['db'] = to_identifier(
48+
name=table.args['db'].this,
49+
quoted=False,
50+
)
4151
elif table.this.name.startswith(catalog_to_remove):
4252
table.args['this'].args['this'] = table.this.name.replace(catalog_to_remove + '.', '')
4353
# sqlglot wants to output the schema/table as a single quoted identifier

0 commit comments

Comments
 (0)