datamarket 0.9.22__tar.gz → 0.9.23__tar.gz
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.
- {datamarket-0.9.22 → datamarket-0.9.23}/PKG-INFO +1 -1
- {datamarket-0.9.22 → datamarket-0.9.23}/pyproject.toml +1 -1
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/interfaces/alchemy.py +15 -20
- {datamarket-0.9.22 → datamarket-0.9.23}/LICENSE +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/README.md +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/__init__.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/interfaces/__init__.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/interfaces/aws.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/interfaces/drive.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/interfaces/ftp.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/interfaces/nominatim.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/interfaces/peerdb.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/interfaces/proxy.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/interfaces/tinybird.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/params/__init__.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/params/nominatim.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/utils/__init__.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/utils/airflow.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/utils/alchemy.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/utils/main.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/utils/selenium.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/utils/soda.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/utils/typer.py +0 -0
- {datamarket-0.9.22 → datamarket-0.9.23}/src/datamarket/utils/types.py +0 -0
|
@@ -188,7 +188,7 @@ class AlchemyInterface:
|
|
|
188
188
|
|
|
189
189
|
query_results.update({column_name: default_value}, synchronize_session=False)
|
|
190
190
|
|
|
191
|
-
def insert_alchemy_obj(self, alchemy_obj: ModelType, silent: bool = False) ->
|
|
191
|
+
def insert_alchemy_obj(self, alchemy_obj: ModelType, silent: bool = False) -> bool:
|
|
192
192
|
if self.session is None:
|
|
193
193
|
raise RuntimeError("Session not active. Use 'with AlchemyInterface(...):' or call start()")
|
|
194
194
|
|
|
@@ -203,8 +203,11 @@ class AlchemyInterface:
|
|
|
203
203
|
if not silent:
|
|
204
204
|
logger.info(f"{alchemy_obj} already in db (savepoint rolled back)")
|
|
205
205
|
# Do not re-raise, allow outer transaction/loop to continue
|
|
206
|
+
return False
|
|
206
207
|
|
|
207
|
-
|
|
208
|
+
return True
|
|
209
|
+
|
|
210
|
+
def upsert_alchemy_obj(self, alchemy_obj: ModelType, index_elements: List[str], silent: bool = False) -> bool:
|
|
208
211
|
if self.session is None:
|
|
209
212
|
raise RuntimeError("Session not active. Use 'with AlchemyInterface(...):' or call start()")
|
|
210
213
|
|
|
@@ -233,6 +236,9 @@ class AlchemyInterface:
|
|
|
233
236
|
if not silent:
|
|
234
237
|
logger.info(f"could not upsert {alchemy_obj} (savepoint rolled back)")
|
|
235
238
|
# Do not re-raise, allow outer transaction/loop to continue
|
|
239
|
+
return False
|
|
240
|
+
|
|
241
|
+
return True
|
|
236
242
|
|
|
237
243
|
def windowed_query(
|
|
238
244
|
self,
|
|
@@ -254,19 +260,13 @@ class AlchemyInterface:
|
|
|
254
260
|
|
|
255
261
|
More info: https://github.com/sqlalchemy/sqlalchemy/wiki/RangeQuery-and-WindowedRangeQuery
|
|
256
262
|
"""
|
|
257
|
-
# Add row_number over the specified order
|
|
258
|
-
row_number = func.row_number().over(order_by=order_by).label("row_number")
|
|
259
|
-
|
|
260
|
-
# Add the windowing column to the statement
|
|
261
|
-
inner_stmt = stmt.with_session(None).add_columns(row_number).order_by(row_number)
|
|
262
|
-
subq = inner_stmt.subquery()
|
|
263
263
|
|
|
264
|
-
#
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
last_row_number = 0
|
|
264
|
+
# Find id column in stmt
|
|
265
|
+
if not any(column.get("entity").id for column in stmt.column_descriptions):
|
|
266
|
+
raise Exception("Column 'id' not found in any entity of the query.")
|
|
267
|
+
id_column = stmt.column_descriptions[0]["entity"].id
|
|
269
268
|
|
|
269
|
+
last_id = 0
|
|
270
270
|
while True:
|
|
271
271
|
session_active = False
|
|
272
272
|
commit_needed = False
|
|
@@ -275,7 +275,7 @@ class AlchemyInterface:
|
|
|
275
275
|
session_active = True
|
|
276
276
|
|
|
277
277
|
# Filter on row_number in the outer query
|
|
278
|
-
current_query =
|
|
278
|
+
current_query = stmt.where(id_column > last_id).order_by(order_by[0], *order_by[1:]).limit(windowsize)
|
|
279
279
|
result = self.session.execute(current_query)
|
|
280
280
|
|
|
281
281
|
# Create a FrozenResult to allow peeking at the data without consuming
|
|
@@ -286,16 +286,11 @@ class AlchemyInterface:
|
|
|
286
286
|
break
|
|
287
287
|
|
|
288
288
|
# Update for next iteration
|
|
289
|
-
|
|
289
|
+
last_id = chunk[-1].id
|
|
290
290
|
|
|
291
291
|
# Create a new Result object from the FrozenResult
|
|
292
292
|
yield_result = frozen_result()
|
|
293
293
|
|
|
294
|
-
# Remove row_number from result before yielding
|
|
295
|
-
# Ensure we don't yield the row_number column itself
|
|
296
|
-
original_col_count = len(cols) - 1
|
|
297
|
-
yield_result = yield_result.columns(*range(original_col_count))
|
|
298
|
-
|
|
299
294
|
yield yield_result
|
|
300
295
|
commit_needed = True
|
|
301
296
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|