Skip to content

Commit 4cdc7fb

Browse files
committed
Add flag for supporting row tracking to engine adapters
1 parent b5db320 commit 4cdc7fb

9 files changed

Lines changed: 19 additions & 9 deletions

File tree

.circleci/continue_config.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,11 @@ workflows:
310310
- athena
311311
- fabric
312312
- gcp-postgres
313-
filters:
314-
branches:
315-
only:
316-
- main
313+
# TODO: uncomment this
314+
# filters:
315+
# branches:
316+
# only:
317+
# - main
317318
- ui_style
318319
- ui_test
319320
- vscode_test

sqlmesh/core/console.py

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

40054005

4006+
# TODO: remove this
40064007
# _CONSOLE: Console = NoopConsole()
40074008
_CONSOLE: Console = TerminalConsole()
40084009

sqlmesh/core/engine_adapter/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ class EngineAdapter:
117117
QUOTE_IDENTIFIERS_IN_VIEWS = True
118118
MAX_IDENTIFIER_LENGTH: t.Optional[int] = None
119119
ATTACH_CORRELATION_ID = True
120+
# TODO: change to False
121+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
120122

121123
def __init__(
122124
self,
@@ -2410,7 +2412,7 @@ def _log_sql(
24102412
def _execute(self, sql: str, track_row_count: bool = False, **kwargs: t.Any) -> None:
24112413
self.cursor.execute(sql, **kwargs)
24122414

2413-
if track_row_count:
2415+
if track_row_count and self.SUPPORTS_QUERY_EXECUTION_TRACKING:
24142416
rowcount_raw = getattr(self.cursor, "rowcount", None)
24152417
rowcount = None
24162418
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
@@ -54,6 +54,7 @@ class MSSQLEngineAdapter(
5454
COMMENT_CREATION_TABLE = CommentCreationTable.UNSUPPORTED
5555
COMMENT_CREATION_VIEW = CommentCreationView.UNSUPPORTED
5656
SUPPORTS_REPLACE_TABLE = False
57+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
5758
SCHEMA_DIFFER = SchemaDiffer(
5859
parameterized_type_defaults={
5960
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
@@ -55,6 +55,7 @@ class TrinoEngineAdapter(
5555
SUPPORTS_REPLACE_TABLE = False
5656
DEFAULT_CATALOG_TYPE = "hive"
5757
QUOTE_IDENTIFIERS_IN_VIEWS = False
58+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
5859
SCHEMA_DIFFER = SchemaDiffer(
5960
parameterized_type_defaults={
6061
# 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
@@ -2407,10 +2407,11 @@ def capture_row_counts(
24072407
assert len(physical_layer_results.materialized_views) == 0
24082408
assert len(physical_layer_results.tables) == len(physical_layer_results.non_temp_tables) == 3
24092409

2410-
assert len(row_counts) == 3
2411-
assert row_counts["seed_model"] == 7
2412-
assert row_counts["incremental_model"] == 7
2413-
assert row_counts["full_model"] == 3
2410+
if ctx.engine_adapter.SUPPORTS_QUERY_EXECUTION_TRACKING:
2411+
assert len(row_counts) == 3
2412+
assert row_counts["seed_model"] == 7
2413+
assert row_counts["incremental_model"] == 7
2414+
assert row_counts["full_model"] == 3
24142415

24152416
# make and validate unmodified dev environment
24162417
no_change_plan: Plan = context.plan_builder(

0 commit comments

Comments
 (0)