Skip to content

Commit d722c67

Browse files
committed
Add flag for supporting row tracking to engine adapters
1 parent 7c46f70 commit d722c67

File tree

9 files changed

+19
-9
lines changed

9 files changed

+19
-9
lines changed

.circleci/continue_config.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,11 @@ workflows:
305305
- clickhouse-cloud
306306
- athena
307307
- gcp-postgres
308-
filters:
309-
branches:
310-
only:
311-
- main
308+
# TODO: uncomment this
309+
# filters:
310+
# branches:
311+
# only:
312+
# - main
312313
- ui_style
313314
- ui_test
314315
- vscode_test

sqlmesh/core/console.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3995,6 +3995,7 @@ def show_table_diff_summary(self, table_diff: TableDiff) -> None:
39953995
self._write(f"Join On: {keys}")
39963996

39973997

3998+
# TODO: remove this
39983999
# _CONSOLE: Console = NoopConsole()
39994000
_CONSOLE: Console = TerminalConsole()
40004001

sqlmesh/core/engine_adapter/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ class EngineAdapter:
112112
QUOTE_IDENTIFIERS_IN_VIEWS = True
113113
MAX_IDENTIFIER_LENGTH: t.Optional[int] = None
114114
ATTACH_CORRELATION_ID = True
115+
# TODO: change to False
116+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
115117

116118
def __init__(
117119
self,
@@ -2282,7 +2284,7 @@ def _log_sql(
22822284
def _execute(self, sql: str, track_row_count: bool = False, **kwargs: t.Any) -> None:
22832285
self.cursor.execute(sql, **kwargs)
22842286

2285-
if track_row_count:
2287+
if track_row_count and self.SUPPORTS_QUERY_EXECUTION_TRACKING:
22862288
rowcount_raw = getattr(self.cursor, "rowcount", None)
22872289
rowcount = None
22882290
if rowcount_raw is not None:

sqlmesh/core/engine_adapter/mssql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class MSSQLEngineAdapter(
5353
COMMENT_CREATION_TABLE = CommentCreationTable.UNSUPPORTED
5454
COMMENT_CREATION_VIEW = CommentCreationView.UNSUPPORTED
5555
SUPPORTS_REPLACE_TABLE = False
56+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
5657
SCHEMA_DIFFER = SchemaDiffer(
5758
parameterized_type_defaults={
5859
exp.DataType.build("DECIMAL", dialect=DIALECT).this: [(18, 0), (0,)],

sqlmesh/core/engine_adapter/mysql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class MySQLEngineAdapter(
4040
MAX_COLUMN_COMMENT_LENGTH = 1024
4141
SUPPORTS_REPLACE_TABLE = False
4242
MAX_IDENTIFIER_LENGTH = 64
43+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
4344
SCHEMA_DIFFER = SchemaDiffer(
4445
parameterized_type_defaults={
4546
exp.DataType.build("BIT", dialect=DIALECT).this: [(1,)],

sqlmesh/core/engine_adapter/postgres.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class PostgresEngineAdapter(
3636
CURRENT_CATALOG_EXPRESSION = exp.column("current_catalog")
3737
SUPPORTS_REPLACE_TABLE = False
3838
MAX_IDENTIFIER_LENGTH = 63
39+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
3940
SCHEMA_DIFFER = SchemaDiffer(
4041
parameterized_type_defaults={
4142
# DECIMAL without precision is "up to 131072 digits before the decimal point; up to 16383 digits after the decimal point"

sqlmesh/core/engine_adapter/trino.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class TrinoEngineAdapter(
5454
SUPPORTS_REPLACE_TABLE = False
5555
DEFAULT_CATALOG_TYPE = "hive"
5656
QUOTE_IDENTIFIERS_IN_VIEWS = False
57+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
5758
SCHEMA_DIFFER = SchemaDiffer(
5859
parameterized_type_defaults={
5960
# default decimal precision varies across backends

sqlmesh/core/execution_tracker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def add_execution(self, sql: str, row_count: t.Optional[int]) -> None:
3131
if row_count is not None and row_count >= 0:
3232
self.total_rows_processed += row_count
3333
self.query_count += 1
34+
# TODO: remove this
3435
# for debugging
3536
self.queries_executed.append((sql[:300], row_count, time.time()))
3637

tests/core/engine_adapter/integration/test_integration.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,10 +1657,11 @@ def capture_row_counts(
16571657
assert len(physical_layer_results.materialized_views) == 0
16581658
assert len(physical_layer_results.tables) == len(physical_layer_results.non_temp_tables) == 3
16591659

1660-
assert len(row_counts) == 3
1661-
assert row_counts["seed_model"] == 7
1662-
assert row_counts["incremental_model"] == 7
1663-
assert row_counts["full_model"] == 3
1660+
if ctx.engine_adapter.SUPPORTS_QUERY_EXECUTION_TRACKING:
1661+
assert len(row_counts) == 3
1662+
assert row_counts["seed_model"] == 7
1663+
assert row_counts["incremental_model"] == 7
1664+
assert row_counts["full_model"] == 3
16641665

16651666
# make and validate unmodified dev environment
16661667
no_change_plan: Plan = context.plan_builder(

0 commit comments

Comments
 (0)