Skip to content

fix(sql_database): reflect timestamp/datetime precision at full_with_precision - #4342

Open
Aryan-Pardeshi wants to merge 1 commit into
dlt-hub:develfrom
Aryan-Pardeshi:fix/4316-timestamp-precision
Open

fix(sql_database): reflect timestamp/datetime precision at full_with_precision#4342
Aryan-Pardeshi wants to merge 1 commit into
dlt-hub:develfrom
Aryan-Pardeshi:fix/4316-timestamp-precision

Conversation

@Aryan-Pardeshi

Copy link
Copy Markdown

Fixes #4316

Problem

sqla_col_to_column_schema never reads .precision from DateTime types, so timestamp/datetime columns lose their fractional-seconds precision even at reflection_level="full_with_precision" (the level explicitly gated by add_precision). Only Numeric, SmallInteger, String, and _Binary had precision handling.

Change

In the DateTime branch, when add_precision is set and the reflected type exposes a precision attribute (e.g. Oracle TIMESTAMP(p), MSSQL DATETIME2(p)), emit col["precision"]. Guarded with getattr since generic sa.DateTime has no such attribute.

Tests

  • test_timestamp_precision_reflected_full_with_precisionDATETIME2(3)precision: 3 at full_with_precision
  • test_timestamp_precision_omitted_without_full_with_precision — no precision key at "full"
  • test_generic_datetime_has_no_precision_key — generic DateTime emits no precision key

Verified: tests/sources/sql_database/test_schema_types.py — 20 passed under SQLAlchemy 2.0.51 and 2.1.0b3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sql_database source: timestamp/datetime column precision is never reflected, at any reflection_level

1 participant