Skip to content

Commit ab8bdcb

Browse files
authored
Revert "Chore!: bump sqlglot to v23.6.3 (#2382)" (#2387)
This reverts commit b44ce65.
1 parent b44ce65 commit ab8bdcb

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"requests",
4747
"rich[jupyter]",
4848
"ruamel.yaml",
49-
"sqlglot[rs]~=23.6.3",
49+
"sqlglot[rs]~=23.3.0",
5050
],
5151
extras_require={
5252
"bigquery": [

sqlmesh/core/engine_adapter/base.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class EngineAdapter:
8787
COMMENT_CREATION_VIEW = CommentCreationView.IN_SCHEMA_DEF_AND_COMMANDS
8888
MAX_TABLE_COMMENT_LENGTH: t.Optional[int] = None
8989
MAX_COLUMN_COMMENT_LENGTH: t.Optional[int] = None
90+
ESCAPE_COMMENT_BACKSLASH = True
9091
INSERT_OVERWRITE_STRATEGY = InsertOverwriteStrategy.DELETE_INSERT
9192
SUPPORTS_MATERIALIZED_VIEWS = False
9293
SUPPORTS_MATERIALIZED_VIEW_SCHEMA = False
@@ -1919,14 +1920,22 @@ def _build_view_properties_exp(
19191920
return exp.Properties(expressions=properties)
19201921
return None
19211922

1922-
def _truncate_comment(self, comment: str, length: t.Optional[int]) -> str:
1923+
def _truncate_comment(
1924+
self, comment: str, length: t.Optional[int], escape_backslash: bool = False
1925+
) -> str:
1926+
if escape_backslash:
1927+
comment = comment.replace("\\", "\\\\")
19231928
return comment[:length] if length else comment
19241929

19251930
def _truncate_table_comment(self, comment: str) -> str:
1926-
return self._truncate_comment(comment, self.MAX_TABLE_COMMENT_LENGTH)
1931+
return self._truncate_comment(
1932+
comment, self.MAX_TABLE_COMMENT_LENGTH, self.ESCAPE_COMMENT_BACKSLASH
1933+
)
19271934

19281935
def _truncate_column_comment(self, comment: str) -> str:
1929-
return self._truncate_comment(comment, self.MAX_COLUMN_COMMENT_LENGTH)
1936+
return self._truncate_comment(
1937+
comment, self.MAX_COLUMN_COMMENT_LENGTH, self.ESCAPE_COMMENT_BACKSLASH
1938+
)
19301939

19311940
def _to_sql(self, expression: exp.Expression, quote: bool = True, **kwargs: t.Any) -> str:
19321941
"""

sqlmesh/core/engine_adapter/bigquery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def _create_column_comments(
445445
comment = column_comments.get(table_def["schema"]["fields"][i]["name"], None)
446446
if comment:
447447
table_def["schema"]["fields"][i]["description"] = self._truncate_comment(
448-
comment, self.MAX_COLUMN_COMMENT_LENGTH
448+
comment, self.MAX_COLUMN_COMMENT_LENGTH, escape_backslash=False
449449
)
450450

451451
# An "etag" is BQ versioning metadata that changes when an object is updated/modified. `update_table`

sqlmesh/core/engine_adapter/mixins.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,13 @@ def _build_view_properties_exp(
221221
return exp.Properties(expressions=properties)
222222
return None
223223

224-
def _truncate_comment(self, comment: str, length: t.Optional[int]) -> str:
224+
def _truncate_comment(
225+
self, comment: str, length: t.Optional[int], escape_backslash: bool = False
226+
) -> str:
225227
# iceberg and delta do not have a comment length limit
226228
if self.current_catalog_type in ("iceberg", "delta"):
227229
return comment
228-
return super()._truncate_comment(comment, length)
230+
return super()._truncate_comment(comment, length, escape_backslash)
229231

230232

231233
class GetCurrentCatalogFromFunctionMixin(EngineAdapter):

sqlmesh/core/engine_adapter/postgres.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class PostgresEngineAdapter(
2929
HAS_VIEW_BINDING = True
3030
CURRENT_CATALOG_EXPRESSION = exp.column("current_catalog")
3131
SUPPORTS_REPLACE_TABLE = False
32+
ESCAPE_COMMENT_BACKSLASH = False
3233

3334
def _fetch_native_df(
3435
self, query: t.Union[exp.Expression, str], quote_identifiers: bool = False

0 commit comments

Comments
 (0)