anysite-cli 0.1.6__py3-none-any.whl → 0.1.7__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.
- anysite/dataset/db_loader.py +48 -4
- {anysite_cli-0.1.6.dist-info → anysite_cli-0.1.7.dist-info}/METADATA +1 -1
- {anysite_cli-0.1.6.dist-info → anysite_cli-0.1.7.dist-info}/RECORD +6 -6
- {anysite_cli-0.1.6.dist-info → anysite_cli-0.1.7.dist-info}/WHEEL +0 -0
- {anysite_cli-0.1.6.dist-info → anysite_cli-0.1.7.dist-info}/entry_points.txt +0 -0
- {anysite_cli-0.1.6.dist-info → anysite_cli-0.1.7.dist-info}/licenses/LICENSE +0 -0
anysite/dataset/db_loader.py
CHANGED
|
@@ -315,8 +315,14 @@ class DatasetDbLoader:
|
|
|
315
315
|
return _extract_dot_value(record, diff_key)
|
|
316
316
|
return record.get(diff_key)
|
|
317
317
|
|
|
318
|
+
# Build field mapping for db_load.fields filtering
|
|
319
|
+
field_mapping = self._get_db_field_mapping(source)
|
|
320
|
+
|
|
318
321
|
# Determine the DB column name for the key
|
|
319
|
-
|
|
322
|
+
if field_mapping and diff_key in field_mapping:
|
|
323
|
+
db_key_col = field_mapping[diff_key]
|
|
324
|
+
else:
|
|
325
|
+
db_key_col = diff_key.replace(".", "_")
|
|
320
326
|
|
|
321
327
|
# INSERT added records
|
|
322
328
|
if result.added:
|
|
@@ -349,15 +355,29 @@ class DatasetDbLoader:
|
|
|
349
355
|
if not changed_fields:
|
|
350
356
|
continue
|
|
351
357
|
|
|
352
|
-
# Build SET clause
|
|
358
|
+
# Build SET clause — only include fields that exist in the DB
|
|
353
359
|
set_parts = []
|
|
354
360
|
params: list[Any] = []
|
|
355
361
|
for field_name in changed_fields:
|
|
356
|
-
|
|
357
|
-
|
|
362
|
+
if field_mapping is not None:
|
|
363
|
+
if field_name not in field_mapping:
|
|
364
|
+
continue
|
|
365
|
+
db_col = field_mapping[field_name]
|
|
366
|
+
else:
|
|
367
|
+
db_col = field_name
|
|
368
|
+
|
|
369
|
+
if "." in field_name:
|
|
370
|
+
new_val = _extract_dot_value(record, field_name)
|
|
371
|
+
else:
|
|
372
|
+
new_val = record.get(field_name)
|
|
373
|
+
|
|
374
|
+
safe_field = sanitize_identifier(db_col)
|
|
358
375
|
set_parts.append(f"{safe_field} = {ph}")
|
|
359
376
|
params.append(new_val)
|
|
360
377
|
|
|
378
|
+
if not set_parts:
|
|
379
|
+
continue
|
|
380
|
+
|
|
361
381
|
params.append(str(key_val))
|
|
362
382
|
sql = (
|
|
363
383
|
f"UPDATE {table_name} "
|
|
@@ -376,6 +396,30 @@ class DatasetDbLoader:
|
|
|
376
396
|
return other.dependency.field
|
|
377
397
|
return None
|
|
378
398
|
|
|
399
|
+
def _get_db_field_mapping(self, source: DatasetSource) -> dict[str, str] | None:
|
|
400
|
+
"""Build mapping of parquet_field -> db_column from db_load.fields.
|
|
401
|
+
|
|
402
|
+
Returns None if no explicit fields configured (all fields allowed).
|
|
403
|
+
"""
|
|
404
|
+
db_load = source.db_load
|
|
405
|
+
if not db_load or not db_load.fields:
|
|
406
|
+
return None
|
|
407
|
+
|
|
408
|
+
mapping: dict[str, str] = {}
|
|
409
|
+
for field_spec in db_load.fields:
|
|
410
|
+
alias = None
|
|
411
|
+
upper = field_spec.upper()
|
|
412
|
+
as_idx = upper.find(" AS ")
|
|
413
|
+
if as_idx != -1:
|
|
414
|
+
alias = field_spec[as_idx + 4:].strip()
|
|
415
|
+
source_field = field_spec[:as_idx].strip()
|
|
416
|
+
else:
|
|
417
|
+
source_field = field_spec
|
|
418
|
+
|
|
419
|
+
col_name = alias or source_field.replace(".", "_")
|
|
420
|
+
mapping[source_field] = col_name
|
|
421
|
+
return mapping
|
|
422
|
+
|
|
379
423
|
def _placeholder(self) -> str:
|
|
380
424
|
"""Get the parameter placeholder for the dialect."""
|
|
381
425
|
if self._dialect == "postgres":
|
|
@@ -21,7 +21,7 @@ anysite/dataset/__init__.py,sha256=J0sKQkGwVOPtvp6pka7LcdeUEADvjWRs71yRuROzJxI,8
|
|
|
21
21
|
anysite/dataset/analyzer.py,sha256=8dsPW32SbSaUTy1F0NIed1U45wjiMgQeJ2iWX7hBxRQ,9245
|
|
22
22
|
anysite/dataset/cli.py,sha256=rEWK1ka-YQ_Vbbj2nMaMYTD9g3wa3ethUWSoaWRSGTY,23066
|
|
23
23
|
anysite/dataset/collector.py,sha256=ZdR3CmQQew_iuJpNtJ4knSrjt0hvkEL4WIaS0IKEkwQ,23927
|
|
24
|
-
anysite/dataset/db_loader.py,sha256=
|
|
24
|
+
anysite/dataset/db_loader.py,sha256=ebx-SJa-w4EjUsuoNqU2wtAWlbXC93kCc9shs3ZHm70,15597
|
|
25
25
|
anysite/dataset/differ.py,sha256=jB_VWTb7UuEBWG9nv1ry5xeo9hmWdhA_cTm6Ed43_Uw,17746
|
|
26
26
|
anysite/dataset/errors.py,sha256=r8cZXoIzSeTGCWpeYjntnN0AduCu74YZyWs3sFu17J4,914
|
|
27
27
|
anysite/dataset/exporters.py,sha256=mA2FYbYJbHfrwkXbHDu4g5qPG_JJKnkVciXFKPkF1Vw,3708
|
|
@@ -58,8 +58,8 @@ anysite/streaming/writer.py,sha256=HfMsC4umUdJuNIAPK57YAxEGyTwUmy-zNrqFkwY6aew,4
|
|
|
58
58
|
anysite/utils/__init__.py,sha256=7SnbxpxKENK-2ecUL5NfnZ9okGI7COKYw4WF46172HM,23
|
|
59
59
|
anysite/utils/fields.py,sha256=bSrHadzNmabL4qubqhXXZoWb_P8KA-3S7_FLVT8nGBc,7410
|
|
60
60
|
anysite/utils/retry.py,sha256=89TbXvavi5t22P2mTYCLAS6SSZoW65gQ0nnYNbYAF0M,2684
|
|
61
|
-
anysite_cli-0.1.
|
|
62
|
-
anysite_cli-0.1.
|
|
63
|
-
anysite_cli-0.1.
|
|
64
|
-
anysite_cli-0.1.
|
|
65
|
-
anysite_cli-0.1.
|
|
61
|
+
anysite_cli-0.1.7.dist-info/METADATA,sha256=RLzLHvkzQ52E6Ovse5FrXEYjJ2P_6X_sGrs_F5ho2Uk,12437
|
|
62
|
+
anysite_cli-0.1.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
63
|
+
anysite_cli-0.1.7.dist-info/entry_points.txt,sha256=FDPxNasy0fRRcOgJdZRVP7Qw01C3TwRa1OwPJiskNyg,45
|
|
64
|
+
anysite_cli-0.1.7.dist-info/licenses/LICENSE,sha256=gVAxkI23CFm4x4HV_fkQYw_bGq93mQmVZEwxNs-YTa4,1069
|
|
65
|
+
anysite_cli-0.1.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|