sqlmesh 0.209.1.dev17__py3-none-any.whl → 0.209.1.dev18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlmesh/_version.py +2 -2
- sqlmesh/core/engine_adapter/bigquery.py +45 -11
- sqlmesh/utils/connection_pool.py +24 -0
- {sqlmesh-0.209.1.dev17.dist-info → sqlmesh-0.209.1.dev18.dist-info}/METADATA +1 -1
- {sqlmesh-0.209.1.dev17.dist-info → sqlmesh-0.209.1.dev18.dist-info}/RECORD +9 -9
- {sqlmesh-0.209.1.dev17.dist-info → sqlmesh-0.209.1.dev18.dist-info}/WHEEL +0 -0
- {sqlmesh-0.209.1.dev17.dist-info → sqlmesh-0.209.1.dev18.dist-info}/entry_points.txt +0 -0
- {sqlmesh-0.209.1.dev17.dist-info → sqlmesh-0.209.1.dev18.dist-info}/licenses/LICENSE +0 -0
- {sqlmesh-0.209.1.dev17.dist-info → sqlmesh-0.209.1.dev18.dist-info}/top_level.txt +0 -0
sqlmesh/_version.py
CHANGED
|
@@ -17,5 +17,5 @@ __version__: str
|
|
|
17
17
|
__version_tuple__: VERSION_TUPLE
|
|
18
18
|
version_tuple: VERSION_TUPLE
|
|
19
19
|
|
|
20
|
-
__version__ = version = '0.209.1.
|
|
21
|
-
__version_tuple__ = version_tuple = (0, 209, 1, '
|
|
20
|
+
__version__ = version = '0.209.1.dev18'
|
|
21
|
+
__version_tuple__ = version_tuple = (0, 209, 1, 'dev18')
|
|
@@ -33,6 +33,7 @@ if t.TYPE_CHECKING:
|
|
|
33
33
|
from google.cloud import bigquery
|
|
34
34
|
from google.cloud.bigquery import StandardSqlDataType
|
|
35
35
|
from google.cloud.bigquery.client import Client as BigQueryClient
|
|
36
|
+
from google.cloud.bigquery.job import QueryJob
|
|
36
37
|
from google.cloud.bigquery.job.base import _AsyncJob as BigQueryQueryResult
|
|
37
38
|
from google.cloud.bigquery.table import Table as BigQueryTable
|
|
38
39
|
|
|
@@ -186,6 +187,31 @@ class BigQueryEngineAdapter(InsertOverwriteWithMergeMixin, ClusteredByMixin, Row
|
|
|
186
187
|
)
|
|
187
188
|
]
|
|
188
189
|
|
|
190
|
+
def close(self) -> t.Any:
|
|
191
|
+
# Cancel all pending query jobs across all threads
|
|
192
|
+
all_query_jobs = self._connection_pool.get_all_attributes("query_job")
|
|
193
|
+
for query_job in all_query_jobs:
|
|
194
|
+
if query_job:
|
|
195
|
+
try:
|
|
196
|
+
if not self._db_call(query_job.done):
|
|
197
|
+
self._db_call(query_job.cancel)
|
|
198
|
+
logger.debug(
|
|
199
|
+
"Cancelled BigQuery job: https://console.cloud.google.com/bigquery?project=%s&j=bq:%s:%s",
|
|
200
|
+
query_job.project,
|
|
201
|
+
query_job.location,
|
|
202
|
+
query_job.job_id,
|
|
203
|
+
)
|
|
204
|
+
except Exception as ex:
|
|
205
|
+
logger.debug(
|
|
206
|
+
"Failed to cancel BigQuery job: https://console.cloud.google.com/bigquery?project=%s&j=bq:%s:%s. %s",
|
|
207
|
+
query_job.project,
|
|
208
|
+
query_job.location,
|
|
209
|
+
query_job.job_id,
|
|
210
|
+
str(ex),
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
return super().close()
|
|
214
|
+
|
|
189
215
|
def _begin_session(self, properties: SessionProperties) -> None:
|
|
190
216
|
from google.cloud.bigquery import QueryJobConfig
|
|
191
217
|
|
|
@@ -318,7 +344,10 @@ class BigQueryEngineAdapter(InsertOverwriteWithMergeMixin, ClusteredByMixin, Row
|
|
|
318
344
|
if len(table.parts) == 3 and "." in table.name:
|
|
319
345
|
# The client's `get_table` method can't handle paths with >3 identifiers
|
|
320
346
|
self.execute(exp.select("*").from_(table).limit(0))
|
|
321
|
-
|
|
347
|
+
query_job = self._query_job
|
|
348
|
+
assert query_job is not None
|
|
349
|
+
|
|
350
|
+
query_results = query_job._query_results
|
|
322
351
|
columns = create_mapping_schema(query_results.schema)
|
|
323
352
|
else:
|
|
324
353
|
bq_table = self._get_table(table)
|
|
@@ -717,7 +746,9 @@ class BigQueryEngineAdapter(InsertOverwriteWithMergeMixin, ClusteredByMixin, Row
|
|
|
717
746
|
self, query: t.Union[exp.Expression, str], quote_identifiers: bool = False
|
|
718
747
|
) -> DF:
|
|
719
748
|
self.execute(query, quote_identifiers=quote_identifiers)
|
|
720
|
-
|
|
749
|
+
query_job = self._query_job
|
|
750
|
+
assert query_job is not None
|
|
751
|
+
return query_job.to_dataframe()
|
|
721
752
|
|
|
722
753
|
def _create_column_comments(
|
|
723
754
|
self,
|
|
@@ -1021,20 +1052,23 @@ class BigQueryEngineAdapter(InsertOverwriteWithMergeMixin, ClusteredByMixin, Row
|
|
|
1021
1052
|
job_config=job_config,
|
|
1022
1053
|
timeout=self._extra_config.get("job_creation_timeout_seconds"),
|
|
1023
1054
|
)
|
|
1055
|
+
query_job = self._query_job
|
|
1056
|
+
assert query_job is not None
|
|
1024
1057
|
|
|
1025
1058
|
logger.debug(
|
|
1026
1059
|
"BigQuery job created: https://console.cloud.google.com/bigquery?project=%s&j=bq:%s:%s",
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1060
|
+
query_job.project,
|
|
1061
|
+
query_job.location,
|
|
1062
|
+
query_job.job_id,
|
|
1030
1063
|
)
|
|
1031
1064
|
|
|
1032
1065
|
results = self._db_call(
|
|
1033
|
-
|
|
1066
|
+
query_job.result,
|
|
1034
1067
|
timeout=self._extra_config.get("job_execution_timeout_seconds"), # type: ignore
|
|
1035
1068
|
)
|
|
1069
|
+
|
|
1036
1070
|
self._query_data = iter(results) if results.total_rows else iter([])
|
|
1037
|
-
query_results =
|
|
1071
|
+
query_results = query_job._query_results
|
|
1038
1072
|
self.cursor._set_rowcount(query_results)
|
|
1039
1073
|
self.cursor._set_description(query_results.schema)
|
|
1040
1074
|
|
|
@@ -1198,15 +1232,15 @@ class BigQueryEngineAdapter(InsertOverwriteWithMergeMixin, ClusteredByMixin, Row
|
|
|
1198
1232
|
|
|
1199
1233
|
@_query_data.setter
|
|
1200
1234
|
def _query_data(self, value: t.Any) -> None:
|
|
1201
|
-
|
|
1235
|
+
self._connection_pool.set_attribute("query_data", value)
|
|
1202
1236
|
|
|
1203
1237
|
@property
|
|
1204
|
-
def _query_job(self) -> t.
|
|
1238
|
+
def _query_job(self) -> t.Optional[QueryJob]:
|
|
1205
1239
|
return self._connection_pool.get_attribute("query_job")
|
|
1206
1240
|
|
|
1207
1241
|
@_query_job.setter
|
|
1208
1242
|
def _query_job(self, value: t.Any) -> None:
|
|
1209
|
-
|
|
1243
|
+
self._connection_pool.set_attribute("query_job", value)
|
|
1210
1244
|
|
|
1211
1245
|
@property
|
|
1212
1246
|
def _session_id(self) -> t.Any:
|
|
@@ -1214,7 +1248,7 @@ class BigQueryEngineAdapter(InsertOverwriteWithMergeMixin, ClusteredByMixin, Row
|
|
|
1214
1248
|
|
|
1215
1249
|
@_session_id.setter
|
|
1216
1250
|
def _session_id(self, value: t.Any) -> None:
|
|
1217
|
-
|
|
1251
|
+
self._connection_pool.set_attribute("session_id", value)
|
|
1218
1252
|
|
|
1219
1253
|
|
|
1220
1254
|
class _ErrorCounter:
|
sqlmesh/utils/connection_pool.py
CHANGED
|
@@ -48,6 +48,17 @@ class ConnectionPool(abc.ABC):
|
|
|
48
48
|
value: Attribute value.
|
|
49
49
|
"""
|
|
50
50
|
|
|
51
|
+
@abc.abstractmethod
|
|
52
|
+
def get_all_attributes(self, key: str) -> t.List[t.Any]:
|
|
53
|
+
"""Returns all attributes with the given key across all connections/threads.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
key: Attribute key.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
List of attribute values from all connections/threads.
|
|
60
|
+
"""
|
|
61
|
+
|
|
51
62
|
@abc.abstractmethod
|
|
52
63
|
def begin(self) -> None:
|
|
53
64
|
"""Starts a new transaction."""
|
|
@@ -142,6 +153,14 @@ class _ThreadLocalBase(_TransactionManagementMixin):
|
|
|
142
153
|
thread_id = get_ident()
|
|
143
154
|
self._thread_attributes[thread_id][key] = value
|
|
144
155
|
|
|
156
|
+
def get_all_attributes(self, key: str) -> t.List[t.Any]:
|
|
157
|
+
"""Returns all attributes with the given key across all threads."""
|
|
158
|
+
return [
|
|
159
|
+
thread_attrs[key]
|
|
160
|
+
for thread_attrs in self._thread_attributes.values()
|
|
161
|
+
if key in thread_attrs
|
|
162
|
+
]
|
|
163
|
+
|
|
145
164
|
def begin(self) -> None:
|
|
146
165
|
self._do_begin()
|
|
147
166
|
with self._thread_transactions_lock:
|
|
@@ -282,6 +301,11 @@ class SingletonConnectionPool(_TransactionManagementMixin):
|
|
|
282
301
|
def set_attribute(self, key: str, value: t.Any) -> None:
|
|
283
302
|
self._attributes[key] = value
|
|
284
303
|
|
|
304
|
+
def get_all_attributes(self, key: str) -> t.List[t.Any]:
|
|
305
|
+
"""Returns all attributes with the given key (single-threaded pool has at most one)."""
|
|
306
|
+
value = self._attributes.get(key)
|
|
307
|
+
return [value] if value is not None else []
|
|
308
|
+
|
|
285
309
|
def begin(self) -> None:
|
|
286
310
|
self._do_begin()
|
|
287
311
|
self._is_transaction_active = True
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
sqlmesh/__init__.py,sha256=QjwaamJIdW7voXoS880yAx7tHm-Im4_mqGA-XJgafos,7631
|
|
2
|
-
sqlmesh/_version.py,sha256=
|
|
2
|
+
sqlmesh/_version.py,sha256=VXqoS95PazQMdQuI-Ud6xRAzmn1s_sL1yIIWZt5amJI,530
|
|
3
3
|
sqlmesh/magics.py,sha256=bEzYqXHcM0P3CjyUZ1O9arlmXAdLAhoglKbQ29fD9AE,41842
|
|
4
4
|
sqlmesh/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
sqlmesh/cicd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -61,7 +61,7 @@ sqlmesh/core/engine_adapter/_typing.py,sha256=_63pYCThfC39UtPVHY3N0H6qJ1YBT32Oqw
|
|
|
61
61
|
sqlmesh/core/engine_adapter/athena.py,sha256=AS1w_l_VrFZsc2CIicElg1dtS9y6q5hHHmTg4ECH-xs,26453
|
|
62
62
|
sqlmesh/core/engine_adapter/base.py,sha256=qefboMkuzRn4ctUyuMZiFtL3tSHBZoMzKcpm_90Nvxw,107386
|
|
63
63
|
sqlmesh/core/engine_adapter/base_postgres.py,sha256=DOsOdCJyQAVfA9S0GznuH0J1bonMqYVP_yJLDYcxFYM,6772
|
|
64
|
-
sqlmesh/core/engine_adapter/bigquery.py,sha256=
|
|
64
|
+
sqlmesh/core/engine_adapter/bigquery.py,sha256=JR7YhT4h6POqE6DhNeBxT83zzDyuHR-dBh3fnmavt18,52811
|
|
65
65
|
sqlmesh/core/engine_adapter/clickhouse.py,sha256=LoPdm_s_s-ZxS1XJPA3Et0iOHeJ1LgqTAFbwBdiqE7A,34912
|
|
66
66
|
sqlmesh/core/engine_adapter/databricks.py,sha256=8ZExPIeT3dDh9MTJW8udvmh9LiY-f9HkRAN1Q5Qebhs,14541
|
|
67
67
|
sqlmesh/core/engine_adapter/duckdb.py,sha256=bv1kfcaDtYlAtJBjxxfteG-dIf31-6r-NipfgtNbFKQ,7133
|
|
@@ -273,7 +273,7 @@ sqlmesh/utils/aws.py,sha256=krxyhrKtsMJDEjT567UbGZogjJ9JRHkvAV-Cg3FVndM,1062
|
|
|
273
273
|
sqlmesh/utils/cache.py,sha256=GITQ3sldwG4vlI0wKIDI7yOr1CND1EI3necAmeCEW8g,4743
|
|
274
274
|
sqlmesh/utils/concurrency.py,sha256=EMgEecfPFN9_2Wjz4TUksJngECGse7fnKVcLswkmhAk,9274
|
|
275
275
|
sqlmesh/utils/config.py,sha256=-SjIn7Z0HHnMtjPavQIvFcSaeg86XLsGd3sGIwOKrTE,1941
|
|
276
|
-
sqlmesh/utils/connection_pool.py,sha256
|
|
276
|
+
sqlmesh/utils/connection_pool.py,sha256=-IYbML9HlDN75uhCu-Y3wdsuhlbscE4T89GDI03F0vY,12252
|
|
277
277
|
sqlmesh/utils/conversions.py,sha256=Ul8u6TzlKzFz_lVrUzFSzmJBKHUXOYe2e-xmkMXV084,406
|
|
278
278
|
sqlmesh/utils/cron.py,sha256=eGwn4iUeiRoQzwcd9eS2TZkut8nR4yWud77N7xQ9CQ0,1829
|
|
279
279
|
sqlmesh/utils/dag.py,sha256=L_jwKf81wCySmt1TFs4vEKsrIHSOPTBhptlmv1bsSSg,7025
|
|
@@ -291,7 +291,7 @@ sqlmesh/utils/pydantic.py,sha256=o_NsXbIpDqNpUA1Uc5xF0ZzoXQYYB0DfHwdRxBwXPNk,120
|
|
|
291
291
|
sqlmesh/utils/rich.py,sha256=cwQ5nJ6sgz64xHtoh6_ec7ReV5YpsOGhMtUJnwoRfEI,3549
|
|
292
292
|
sqlmesh/utils/windows.py,sha256=r7Yin4WEwbvH7sKA3hOJtRsclmscNuBeCklCfVPvtQs,611
|
|
293
293
|
sqlmesh/utils/yaml.py,sha256=hvo5lmybYLcIx4p6CQwufS8X4MbwS60lEBnCmYJCXmU,2336
|
|
294
|
-
sqlmesh-0.209.1.
|
|
294
|
+
sqlmesh-0.209.1.dev18.dist-info/licenses/LICENSE,sha256=OlMefUjgWJdULtf84BLW0AZZcY8DwdgQqb_1j2862j8,11346
|
|
295
295
|
sqlmesh_dbt/__init__.py,sha256=awYS5y5mz-1NUmx6i5h5NSTJ7tidRl9NC0FAnFWSF6U,350
|
|
296
296
|
sqlmesh_dbt/cli.py,sha256=Ekn77WLMmyyr31aoDoWrZp5DS0rfiddy7pNohBK8G0s,2115
|
|
297
297
|
sqlmesh_dbt/console.py,sha256=1B0B5_R1DlrEkyWVDl8G78-B6_K-ZtLPsQEhqPCfLEU,188
|
|
@@ -413,8 +413,8 @@ web/server/api/endpoints/models.py,sha256=kwj0s7uve3iZSMfmjkoPVMFMeY1sD0peTeyrWf
|
|
|
413
413
|
web/server/api/endpoints/modules.py,sha256=8hqqgonGay_mJmpCw0IdbjsPhWlQH2VLdKAqha-myac,468
|
|
414
414
|
web/server/api/endpoints/plan.py,sha256=bbbY50W_2MsZSTxOHWMKz0tbIm75nsRSlPy8GI2fg9Q,9306
|
|
415
415
|
web/server/api/endpoints/table_diff.py,sha256=SCy3-pr5x6bEEiOaZGCDbiHQhpgxwmnz3Acqa2Ie6jI,2090
|
|
416
|
-
sqlmesh-0.209.1.
|
|
417
|
-
sqlmesh-0.209.1.
|
|
418
|
-
sqlmesh-0.209.1.
|
|
419
|
-
sqlmesh-0.209.1.
|
|
420
|
-
sqlmesh-0.209.1.
|
|
416
|
+
sqlmesh-0.209.1.dev18.dist-info/METADATA,sha256=DhsqsAAfCLUo_qjBGTON1HbyNiXLjtm-eXvr1DlrUso,26686
|
|
417
|
+
sqlmesh-0.209.1.dev18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
418
|
+
sqlmesh-0.209.1.dev18.dist-info/entry_points.txt,sha256=sHAf6tQczIM8xZoduN4qaUjV7QEPVUUW_LCT8EDUMv4,155
|
|
419
|
+
sqlmesh-0.209.1.dev18.dist-info/top_level.txt,sha256=RQ-33FPe2IgL0rgossAfJkCRtqslz9b7wFARqiWLC5Q,24
|
|
420
|
+
sqlmesh-0.209.1.dev18.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|