Skip to content

Commit 66827cd

Browse files
committed
Add flag for supporting row tracking to engine adapters
1 parent 8549479 commit 66827cd

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
@@ -4029,6 +4029,7 @@ def show_table_diff_summary(self, table_diff: TableDiff) -> None:
40294029
self._write(f"Join On: {keys}")
40304030

40314031

4032+
# TODO: remove this
40324033
# _CONSOLE: Console = NoopConsole()
40334034
_CONSOLE: Console = TerminalConsole()
40344035

sqlmesh/core/engine_adapter/base.py

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

122124
def __init__(
123125
self,
@@ -2442,7 +2444,7 @@ def _log_sql(
24422444
def _execute(self, sql: str, track_row_count: bool = False, **kwargs: t.Any) -> None:
24432445
self.cursor.execute(sql, **kwargs)
24442446

2445-
if track_row_count:
2447+
if track_row_count and self.SUPPORTS_QUERY_EXECUTION_TRACKING:
24462448
rowcount_raw = getattr(self.cursor, "rowcount", None)
24472449
rowcount = None
24482450
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_KWARGS = {
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
@@ -39,6 +39,7 @@ class MySQLEngineAdapter(
3939
MAX_COLUMN_COMMENT_LENGTH = 1024
4040
SUPPORTS_REPLACE_TABLE = False
4141
MAX_IDENTIFIER_LENGTH = 64
42+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
4243
SCHEMA_DIFFER_KWARGS = {
4344
"parameterized_type_defaults": {
4445
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
@@ -35,6 +35,7 @@ class PostgresEngineAdapter(
3535
CURRENT_CATALOG_EXPRESSION = exp.column("current_catalog")
3636
SUPPORTS_REPLACE_TABLE = False
3737
MAX_IDENTIFIER_LENGTH = 63
38+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
3839
SCHEMA_DIFFER_KWARGS = {
3940
"parameterized_type_defaults": {
4041
# 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
SUPPORTED_DROP_CASCADE_OBJECT_KINDS = ["SCHEMA"]
5656
DEFAULT_CATALOG_TYPE = "hive"
5757
QUOTE_IDENTIFIERS_IN_VIEWS = False
58+
SUPPORTS_QUERY_EXECUTION_TRACKING = True
5859
SCHEMA_DIFFER_KWARGS = {
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
@@ -2451,10 +2451,11 @@ def capture_row_counts(
24512451
assert len(physical_layer_results.materialized_views) == 0
24522452
assert len(physical_layer_results.tables) == len(physical_layer_results.non_temp_tables) == 3
24532453

2454-
assert len(row_counts) == 3
2455-
assert row_counts["seed_model"] == 7
2456-
assert row_counts["incremental_model"] == 7
2457-
assert row_counts["full_model"] == 3
2454+
if ctx.engine_adapter.SUPPORTS_QUERY_EXECUTION_TRACKING:
2455+
assert len(row_counts) == 3
2456+
assert row_counts["seed_model"] == 7
2457+
assert row_counts["incremental_model"] == 7
2458+
assert row_counts["full_model"] == 3
24582459

24592460
# make and validate unmodified dev environment
24602461
no_change_plan: Plan = context.plan_builder(

0 commit comments

Comments
 (0)