| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…CT path (#786) Signed-off-by: peco-engineer-bot[bot] <3815206+peco-engineer-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: 1 Medium · 1 Low
Targeted, well-tested fix that correctly recovers the TIMESTAMP_NTZ distinction on the Thrift SELECT path via the existing Arrow-metadata override. One medium concern: the PEP-249 DATETIME type object still only matches "timestamp", so NTZ columns silently stop comparing equal to DATETIME — a contract regression worth addressing. Also flagged a low cross-backend consistency gap on the SEA conversion path.
DBAPITypeObject.__eq__ matches only the exact strings passed at construction, and DATETIME is constructed with just "timestamp". Before this PR a TIMESTAMP_NTZ column collapsed to type_code "timestamp", so cursor.description[i][1] == databricks.sql.DATETIME returned True. After this PR the type_code becomes "timestamp_ntz", so that comparison now returns False for NTZ columns — even though PEP-249 intends DATETIME to cover all datetime-family types. Downstream consumers (e.g. SQLAlchemy/pandas adapters) that test col_type == DATETIME will silently stop recognizing NTZ columns as datetimes.
Consider extending DATETIME to also match "timestamp_ntz", and adding an assertion to the E2E test that description[1][1] == DATETIME still holds.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Automated fix for #786 — Cursor.description collapses TIMESTAMP_NTZ to 'timestamp' on the SELECT path.
Extended the existing Spark:DataType:SqlName Arrow-metadata override in _col_to_description (thrift_backend.py) to map b"TIMESTAMP_NTZ" to type_code "timestamp_ntz", recovering the distinction that Thrift collapses (both TIMESTAMP and TIMESTAMP_NTZ arrive as TTypeId.TIMESTAMP_TYPE); also taught convert_to_assigned_datatypes_in_column_table (utils.py) to parse the new "timestamp_ntz" type_code like "timestamp". Verified via a live-warehouse E2E test (description[1][1] == 'timestamp_ntz', description[0][1] == 'timestamp') plus two unit tests; full unit suite (82 tests) stays green.
Root cause & plan
Root cause: In src/databricks/sql/backend/thrift_backend.py, _col_to_description derives the DB-API type_code from the Thrift TTypeId enum name. Spark TIMESTAMP and TIMESTAMP_NTZ both arrive over the wire as TTypeId.TIMESTAMP_TYPE, so after stripping _TYPE and lowercasing both become 'timestamp'. The function already has a Spark:DataType:SqlName Arrow-metadata override hook (added by PR #560) that recovers VARIANT, but it does not handle TIMESTAMP_NTZ, so the _NTZ distinction is lost on the SELECT path.
Files: src/databricks/sql/backend/thrift_backend.py, tests/e2e/test_driver.py, tests/unit/test_util.py
Planned coverage:
Files changed
Test plan
🤖 Generated by engineer-bot (bug-fix flow) — review before merge.