Skip to content

Commit 6eaa149

Browse files
committed
UPD: Merged Sqlglot into the branch and addressed feedback
1 parent 80277b1 commit 6eaa149

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

dlt/destinations/impl/sqlalchemy/merge_job.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,12 @@ def gen_scd2_sql(
375375
format_datetime_literal = (
376376
DestinationCapabilitiesContext.generic_capabilities().format_datetime_literal
377377
)
378-
created_at = current_load_package()["state"]["created_at"]
379378
_boundary_ts = cast(Optional[TAnyDateTime], root_table.get("x-boundary-timestamp"))
380-
boundary_ts: TAnyDateTime = _boundary_ts if _boundary_ts is not None else created_at
379+
boundary_ts: TAnyDateTime = (
380+
_boundary_ts
381+
if _boundary_ts is not None
382+
else current_load_package()["state"]["created_at"]
383+
)
381384
boundary_ts = ensure_pendulum_datetime_utc(boundary_ts)
382385

383386
boundary_literal = format_datetime_literal(boundary_ts, caps.timestamp_precision)

dlt/extract/hints.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -823,24 +823,21 @@ def validate_write_disposition_hint(template: TResourceHints) -> None:
823823

824824
if wd.get("strategy") == "scd2":
825825
wd = cast(TScd2StrategyDict, wd)
826-
827-
art = wd.get("active_record_timestamp")
828-
if art is not None:
829-
try:
830-
ensure_pendulum_datetime_utc(art)
831-
except (ValueError, TypeError) as exc:
832-
raise ValueError(
833-
f"could not parse `active_record_timestamp` value `{art}`"
834-
) from exc
835-
836-
bt = wd.get("boundary_timestamp")
837-
if bt is not None:
838-
try:
839-
ensure_pendulum_datetime_utc(bt)
840-
except (ValueError, TypeError) as exc:
841-
raise ValueError(
842-
f"could not parse `boundary_timestamp` value `{bt}`"
843-
) from exc
826+
for ts in ("active_record_timestamp", "boundary_timestamp"):
827+
if (
828+
ts == "active_record_timestamp"
829+
and wd.get("active_record_timestamp") is None
830+
):
831+
continue # None is allowed for active_record_timestamp
832+
if ts in wd:
833+
if wd[ts] is None: # type: ignore[literal-required]
834+
continue
835+
try:
836+
ensure_pendulum_datetime_utc(wd[ts]) # type: ignore[literal-required]
837+
except Exception:
838+
raise ValueError(
839+
f"could not parse `{ts}` value `{wd[ts]}`" # type: ignore[literal-required]
840+
)
844841

845842
@staticmethod
846843
def validate_reference_hint(template: TResourceHints) -> None:

0 commit comments

Comments
 (0)