Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"requests",
"rich[jupyter]",
"ruamel.yaml",
"sqlglot[rs]~=23.3.0",
"sqlglot[rs]~=23.6.3",
],
extras_require={
"bigquery": [
Expand Down
15 changes: 3 additions & 12 deletions sqlmesh/core/engine_adapter/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class EngineAdapter:
COMMENT_CREATION_VIEW = CommentCreationView.IN_SCHEMA_DEF_AND_COMMANDS
MAX_TABLE_COMMENT_LENGTH: t.Optional[int] = None
MAX_COLUMN_COMMENT_LENGTH: t.Optional[int] = None
ESCAPE_COMMENT_BACKSLASH = True
INSERT_OVERWRITE_STRATEGY = InsertOverwriteStrategy.DELETE_INSERT
SUPPORTS_MATERIALIZED_VIEWS = False
SUPPORTS_MATERIALIZED_VIEW_SCHEMA = False
Expand Down Expand Up @@ -1920,22 +1919,14 @@ def _build_view_properties_exp(
return exp.Properties(expressions=properties)
return None

def _truncate_comment(
self, comment: str, length: t.Optional[int], escape_backslash: bool = False
) -> str:
if escape_backslash:
comment = comment.replace("\\", "\\\\")
def _truncate_comment(self, comment: str, length: t.Optional[int]) -> str:
return comment[:length] if length else comment

def _truncate_table_comment(self, comment: str) -> str:
return self._truncate_comment(
comment, self.MAX_TABLE_COMMENT_LENGTH, self.ESCAPE_COMMENT_BACKSLASH
)
return self._truncate_comment(comment, self.MAX_TABLE_COMMENT_LENGTH)

def _truncate_column_comment(self, comment: str) -> str:
return self._truncate_comment(
comment, self.MAX_COLUMN_COMMENT_LENGTH, self.ESCAPE_COMMENT_BACKSLASH
)
return self._truncate_comment(comment, self.MAX_COLUMN_COMMENT_LENGTH)

def _to_sql(self, expression: exp.Expression, quote: bool = True, **kwargs: t.Any) -> str:
"""
Expand Down
2 changes: 1 addition & 1 deletion sqlmesh/core/engine_adapter/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def _create_column_comments(
comment = column_comments.get(table_def["schema"]["fields"][i]["name"], None)
if comment:
table_def["schema"]["fields"][i]["description"] = self._truncate_comment(
comment, self.MAX_COLUMN_COMMENT_LENGTH, escape_backslash=False
comment, self.MAX_COLUMN_COMMENT_LENGTH
)

# An "etag" is BQ versioning metadata that changes when an object is updated/modified. `update_table`
Expand Down
6 changes: 2 additions & 4 deletions sqlmesh/core/engine_adapter/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,11 @@ def _build_view_properties_exp(
return exp.Properties(expressions=properties)
return None

def _truncate_comment(
self, comment: str, length: t.Optional[int], escape_backslash: bool = False
) -> str:
def _truncate_comment(self, comment: str, length: t.Optional[int]) -> str:
# iceberg and delta do not have a comment length limit
if self.current_catalog_type in ("iceberg", "delta"):
return comment
return super()._truncate_comment(comment, length, escape_backslash)
return super()._truncate_comment(comment, length)


class GetCurrentCatalogFromFunctionMixin(EngineAdapter):
Expand Down
1 change: 0 additions & 1 deletion sqlmesh/core/engine_adapter/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class PostgresEngineAdapter(
HAS_VIEW_BINDING = True
CURRENT_CATALOG_EXPRESSION = exp.column("current_catalog")
SUPPORTS_REPLACE_TABLE = False
ESCAPE_COMMENT_BACKSLASH = False

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