Skip to content

Commit 7144154

Browse files
committed
Change tracking arg name to track_rows_processed
1 parent 4cb0de3 commit 7144154

14 files changed

Lines changed: 44 additions & 44 deletions

File tree

sqlmesh/core/console.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4306,7 +4306,7 @@ def _calculate_annotation_str_len(
43064306
# Convert number of bytes to a human-readable string
43074307
# https://github.com/dbt-labs/dbt-adapters/blob/34fd178539dcb6f82e18e738adc03de7784c032f/dbt-bigquery/src/dbt/adapters/bigquery/connections.py#L165
43084308
def _format_bytes(num_bytes: t.Optional[int]) -> str:
4309-
if num_bytes and num_bytes > 0:
4309+
if num_bytes and num_bytes >= 0:
43104310
if num_bytes < 1024:
43114311
return f"{num_bytes} bytes"
43124312

@@ -4324,7 +4324,7 @@ def _format_bytes(num_bytes: t.Optional[int]) -> str:
43244324
# Abbreviate integer count. Example: 1,000,000,000 -> 1b
43254325
# https://github.com/dbt-labs/dbt-adapters/blob/34fd178539dcb6f82e18e738adc03de7784c032f/dbt-bigquery/src/dbt/adapters/bigquery/connections.py#L178
43264326
def _abbreviate_integer_count(count: t.Optional[int]) -> str:
4327-
if count and count > 0:
4327+
if count and count >= 0:
43284328
if count < 1000:
43294329
return str(count)
43304330

sqlmesh/core/engine_adapter/base.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ def _create_table_from_source_queries(
845845
table_description: t.Optional[str] = None,
846846
column_descriptions: t.Optional[t.Dict[str, str]] = None,
847847
table_kind: t.Optional[str] = None,
848-
track_execution_stats: bool = True,
848+
track_rows_processed: bool = True,
849849
**kwargs: t.Any,
850850
) -> None:
851851
table = exp.to_table(table_name)
@@ -891,15 +891,15 @@ def _create_table_from_source_queries(
891891
replace=replace,
892892
table_description=table_description,
893893
table_kind=table_kind,
894-
track_execution_stats=track_execution_stats,
894+
track_rows_processed=track_rows_processed,
895895
**kwargs,
896896
)
897897
else:
898898
self._insert_append_query(
899899
table_name,
900900
query,
901901
target_columns_to_types or self.columns(table),
902-
track_execution_stats=track_execution_stats,
902+
track_rows_processed=track_rows_processed,
903903
)
904904

905905
# Register comments with commands if the engine supports comments and we weren't able to
@@ -923,7 +923,7 @@ def _create_table(
923923
table_description: t.Optional[str] = None,
924924
column_descriptions: t.Optional[t.Dict[str, str]] = None,
925925
table_kind: t.Optional[str] = None,
926-
track_execution_stats: bool = True,
926+
track_rows_processed: bool = True,
927927
**kwargs: t.Any,
928928
) -> None:
929929
self.execute(
@@ -941,7 +941,7 @@ def _create_table(
941941
table_kind=table_kind,
942942
**kwargs,
943943
),
944-
track_execution_stats=track_execution_stats,
944+
track_rows_processed=track_rows_processed,
945945
)
946946

947947
def _build_create_table_exp(
@@ -1429,7 +1429,7 @@ def insert_append(
14291429
table_name: TableName,
14301430
query_or_df: QueryOrDF,
14311431
target_columns_to_types: t.Optional[t.Dict[str, exp.DataType]] = None,
1432-
track_execution_stats: bool = True,
1432+
track_rows_processed: bool = True,
14331433
source_columns: t.Optional[t.List[str]] = None,
14341434
) -> None:
14351435
source_queries, target_columns_to_types = self._get_source_queries_and_columns_to_types(
@@ -1439,15 +1439,15 @@ def insert_append(
14391439
source_columns=source_columns,
14401440
)
14411441
self._insert_append_source_queries(
1442-
table_name, source_queries, target_columns_to_types, track_execution_stats
1442+
table_name, source_queries, target_columns_to_types, track_rows_processed
14431443
)
14441444

14451445
def _insert_append_source_queries(
14461446
self,
14471447
table_name: TableName,
14481448
source_queries: t.List[SourceQuery],
14491449
target_columns_to_types: t.Optional[t.Dict[str, exp.DataType]] = None,
1450-
track_execution_stats: bool = True,
1450+
track_rows_processed: bool = True,
14511451
) -> None:
14521452
with self.transaction(condition=len(source_queries) > 0):
14531453
target_columns_to_types = target_columns_to_types or self.columns(table_name)
@@ -1457,7 +1457,7 @@ def _insert_append_source_queries(
14571457
table_name,
14581458
query,
14591459
target_columns_to_types,
1460-
track_execution_stats=track_execution_stats,
1460+
track_rows_processed=track_rows_processed,
14611461
)
14621462

14631463
def _insert_append_query(
@@ -1466,13 +1466,13 @@ def _insert_append_query(
14661466
query: Query,
14671467
target_columns_to_types: t.Dict[str, exp.DataType],
14681468
order_projections: bool = True,
1469-
track_execution_stats: bool = True,
1469+
track_rows_processed: bool = True,
14701470
) -> None:
14711471
if order_projections:
14721472
query = self._order_projections_and_filter(query, target_columns_to_types)
14731473
self.execute(
14741474
exp.insert(query, table_name, columns=list(target_columns_to_types)),
1475-
track_execution_stats=track_execution_stats,
1475+
track_rows_processed=track_rows_processed,
14761476
)
14771477

14781478
def insert_overwrite_by_partition(
@@ -1615,7 +1615,7 @@ def _insert_overwrite_by_condition(
16151615
)
16161616
if insert_overwrite_strategy.is_replace_where:
16171617
insert_exp.set("where", where or exp.true())
1618-
self.execute(insert_exp, track_execution_stats=True)
1618+
self.execute(insert_exp, track_rows_processed=True)
16191619

16201620
def update_table(
16211621
self,
@@ -1637,7 +1637,7 @@ def _merge(
16371637
exp.Subquery(this=query), alias=MERGE_SOURCE_ALIAS, copy=False, table=True
16381638
)
16391639
self.execute(
1640-
exp.Merge(this=this, using=using, on=on, whens=whens), track_execution_stats=True
1640+
exp.Merge(this=this, using=using, on=on, whens=whens), track_rows_processed=True
16411641
)
16421642

16431643
def scd_type_2_by_time(
@@ -2387,7 +2387,7 @@ def execute(
23872387
expressions: t.Union[str, exp.Expression, t.Sequence[exp.Expression]],
23882388
ignore_unsupported_errors: bool = False,
23892389
quote_identifiers: bool = True,
2390-
track_execution_stats: bool = False,
2390+
track_rows_processed: bool = False,
23912391
**kwargs: t.Any,
23922392
) -> None:
23932393
"""Execute a sql query."""
@@ -2409,7 +2409,7 @@ def execute(
24092409
expression=e if isinstance(e, exp.Expression) else None,
24102410
quote_identifiers=quote_identifiers,
24112411
)
2412-
self._execute(sql, track_execution_stats, **kwargs)
2412+
self._execute(sql, track_rows_processed, **kwargs)
24132413

24142414
def _attach_correlation_id(self, sql: str) -> str:
24152415
if self.ATTACH_CORRELATION_ID and self.correlation_id:
@@ -2439,12 +2439,12 @@ def _record_execution_stats(
24392439
) -> None:
24402440
QueryExecutionTracker.record_execution(sql, rowcount, bytes_processed)
24412441

2442-
def _execute(self, sql: str, track_execution_stats: bool = False, **kwargs: t.Any) -> None:
2442+
def _execute(self, sql: str, track_rows_processed: bool = False, **kwargs: t.Any) -> None:
24432443
self.cursor.execute(sql, **kwargs)
24442444

24452445
if (
24462446
self.SUPPORTS_QUERY_EXECUTION_TRACKING
2447-
and track_execution_stats
2447+
and track_rows_processed
24482448
and QueryExecutionTracker.is_tracking()
24492449
):
24502450
rowcount_raw = getattr(self.cursor, "rowcount", None)
@@ -2501,7 +2501,7 @@ def temp_table(
25012501
exists=True,
25022502
table_description=None,
25032503
column_descriptions=None,
2504-
track_execution_stats=False,
2504+
track_rows_processed=False,
25052505
**kwargs,
25062506
)
25072507

@@ -2753,7 +2753,7 @@ def _replace_by_key(
27532753
insert_statement.set("where", delete_filter)
27542754
insert_statement.set("this", exp.to_table(target_table))
27552755

2756-
self.execute(insert_statement, track_execution_stats=True)
2756+
self.execute(insert_statement, track_rows_processed=True)
27572757
finally:
27582758
self.drop_table(temp_table)
27592759

sqlmesh/core/engine_adapter/bigquery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ def _db_call(self, func: t.Callable[..., t.Any], *args: t.Any, **kwargs: t.Any)
10521052
def _execute(
10531053
self,
10541054
sql: str,
1055-
track_execution_stats: bool = False,
1055+
track_rows_processed: bool = False,
10561056
**kwargs: t.Any,
10571057
) -> None:
10581058
"""Execute a sql query."""
@@ -1098,7 +1098,7 @@ def _execute(
10981098
self.cursor._set_rowcount(query_results)
10991099
self.cursor._set_description(query_results.schema)
11001100

1101-
if track_execution_stats and QueryExecutionTracker.is_tracking():
1101+
if track_rows_processed and QueryExecutionTracker.is_tracking():
11021102
num_rows = None
11031103
if query_job.statement_type == "CREATE_TABLE_AS_SELECT":
11041104
# since table was just created, number rows in table == number rows processed

sqlmesh/core/engine_adapter/clickhouse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def _insert_overwrite_by_condition(
294294
)
295295

296296
try:
297-
self.execute(existing_records_insert_exp, track_execution_stats=True)
297+
self.execute(existing_records_insert_exp, track_rows_processed=True)
298298
finally:
299299
if table_partition_exp:
300300
self.drop_table(partitions_temp_table_name)
@@ -489,7 +489,7 @@ def _create_table(
489489
table_description: t.Optional[str] = None,
490490
column_descriptions: t.Optional[t.Dict[str, str]] = None,
491491
table_kind: t.Optional[str] = None,
492-
track_execution_stats: bool = True,
492+
track_rows_processed: bool = True,
493493
**kwargs: t.Any,
494494
) -> None:
495495
"""Creates a table in the database.
@@ -526,7 +526,7 @@ def _create_table(
526526
column_descriptions,
527527
table_kind,
528528
empty_ctas=(self.engine_run_mode.is_cloud and expression is not None),
529-
track_execution_stats=track_execution_stats,
529+
track_rows_processed=track_rows_processed,
530530
**kwargs,
531531
)
532532

sqlmesh/core/engine_adapter/duckdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def _create_table(
157157
table_description: t.Optional[str] = None,
158158
column_descriptions: t.Optional[t.Dict[str, str]] = None,
159159
table_kind: t.Optional[str] = None,
160-
track_execution_stats: bool = True,
160+
track_rows_processed: bool = True,
161161
**kwargs: t.Any,
162162
) -> None:
163163
catalog = self.get_current_catalog()
@@ -181,7 +181,7 @@ def _create_table(
181181
table_description,
182182
column_descriptions,
183183
table_kind,
184-
track_execution_stats=track_execution_stats,
184+
track_rows_processed=track_rows_processed,
185185
**kwargs,
186186
)
187187

sqlmesh/core/engine_adapter/redshift.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def _create_table_from_source_queries(
174174
table_description: t.Optional[str] = None,
175175
column_descriptions: t.Optional[t.Dict[str, str]] = None,
176176
table_kind: t.Optional[str] = None,
177-
track_execution_stats: bool = True,
177+
track_rows_processed: bool = True,
178178
**kwargs: t.Any,
179179
) -> None:
180180
"""
@@ -429,7 +429,7 @@ def resolve_target_table(expression: exp.Expression) -> exp.Expression:
429429
on=on.transform(resolve_target_table),
430430
whens=whens.transform(resolve_target_table),
431431
),
432-
track_execution_stats=True,
432+
track_rows_processed=True,
433433
)
434434

435435
def _normalize_decimal_value(self, expr: exp.Expression, precision: int) -> exp.Expression:

sqlmesh/core/engine_adapter/snowflake.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def _create_table(
170170
table_description: t.Optional[str] = None,
171171
column_descriptions: t.Optional[t.Dict[str, str]] = None,
172172
table_kind: t.Optional[str] = None,
173-
track_execution_stats: bool = True,
173+
track_rows_processed: bool = True,
174174
**kwargs: t.Any,
175175
) -> None:
176176
table_format = kwargs.get("table_format")
@@ -190,7 +190,7 @@ def _create_table(
190190
table_description=table_description,
191191
column_descriptions=column_descriptions,
192192
table_kind=table_kind,
193-
track_execution_stats=track_execution_stats,
193+
track_rows_processed=track_rows_processed,
194194
**kwargs,
195195
)
196196

sqlmesh/core/engine_adapter/spark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ def _create_table(
434434
table_description: t.Optional[str] = None,
435435
column_descriptions: t.Optional[t.Dict[str, str]] = None,
436436
table_kind: t.Optional[str] = None,
437-
track_execution_stats: bool = True,
437+
track_rows_processed: bool = True,
438438
**kwargs: t.Any,
439439
) -> None:
440440
table_name = (
@@ -463,7 +463,7 @@ def _create_table(
463463
target_columns_to_types=target_columns_to_types,
464464
table_description=table_description,
465465
column_descriptions=column_descriptions,
466-
track_execution_stats=track_execution_stats,
466+
track_rows_processed=track_rows_processed,
467467
**kwargs,
468468
)
469469
table_name = (

sqlmesh/core/engine_adapter/trino.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _create_table(
359359
table_description: t.Optional[str] = None,
360360
column_descriptions: t.Optional[t.Dict[str, str]] = None,
361361
table_kind: t.Optional[str] = None,
362-
track_execution_stats: bool = True,
362+
track_rows_processed: bool = True,
363363
**kwargs: t.Any,
364364
) -> None:
365365
super()._create_table(
@@ -371,7 +371,7 @@ def _create_table(
371371
table_description=table_description,
372372
column_descriptions=column_descriptions,
373373
table_kind=table_kind,
374-
track_execution_stats=track_execution_stats,
374+
track_rows_processed=track_rows_processed,
375375
**kwargs,
376376
)
377377

sqlmesh/core/state_sync/db/environment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def update_environment(self, environment: Environment) -> None:
7878
self.environments_table,
7979
_environment_to_df(environment),
8080
target_columns_to_types=self._environment_columns_to_types,
81-
track_execution_stats=False,
81+
track_rows_processed=False,
8282
)
8383

8484
def update_environment_statements(
@@ -109,7 +109,7 @@ def update_environment_statements(
109109
self.environment_statements_table,
110110
_environment_statements_to_df(environment_name, plan_id, environment_statements),
111111
target_columns_to_types=self._environment_statements_columns_to_types,
112-
track_execution_stats=False,
112+
track_rows_processed=False,
113113
)
114114

115115
def invalidate_environment(self, name: str, protect_prod: bool = True) -> None:

0 commit comments

Comments
 (0)