Skip to content

Commit 5f04d66

Browse files
raghulravi0509mohittilala
authored andcommitted
quote identifiers in GET_DDL queries to support special characters (#26007)
* quote identifiers in GET_DDL queries to support special characters - Fixed get_table_ddl() to quote schema and table identifiers - Fixed get_view_definition() to quote identifiers when schema is None - Fixed get_stream_definition() to quote schema and stream identifiers - Supports tables with dots and other special characters (e.g., CDB_LU_AP.DSPA_ADDRESSES_INITIAL_LOAD) Fixes: 26006" * Fix DDL identifier quoting for Snowflake to support schema.table format --------- Co-authored-by: Mohit Tilala <63147650+mohittilala@users.noreply.github.com> (cherry picked from commit ca7e1b1)
1 parent da91c9b commit 5f04d66

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • ingestion/src/metadata/ingestion/source/database/snowflake

ingestion/src/metadata/ingestion/source/database/snowflake/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def get_view_definition(
352352
)
353353

354354
schema = schema or self.default_schema_name
355-
view_name = f'"{schema}"."{table_name}"' if schema else table_name
355+
view_name = f'"{schema}"."{table_name}"' if schema else f'"{table_name}"'
356356
cursor = connection.execute(SNOWFLAKE_GET_VIEW_DDL.format(view_name=view_name))
357357
try:
358358
result = cursor.fetchone()
@@ -371,7 +371,7 @@ def get_stream_definition( # pylint: disable=unused-argument
371371
Gets the stream definition
372372
"""
373373
schema = schema or self.default_schema_name
374-
stream_name = f"{schema}.{stream_name}" if schema else stream_name
374+
stream_name = f'"{schema}"."{stream_name}"' if schema else f'"{stream_name}"'
375375
cursor = connection.execute(
376376
SNOWFLAKE_GET_STREAM_DEFINITION.format(stream_name=stream_name)
377377
)
@@ -644,7 +644,7 @@ def get_table_ddl(
644644
Gets the Table DDL
645645
"""
646646
schema = schema or self.default_schema_name
647-
table_name = f"{schema}.{table_name}" if schema else table_name
647+
table_name = f'"{schema}"."{table_name}"' if schema else f'"{table_name}"'
648648
cursor = connection.execute(SNOWFLAKE_GET_TABLE_DDL.format(table_name=table_name))
649649
try:
650650
result = cursor.fetchone()

0 commit comments

Comments
 (0)