Repository navigation
fix(thrift, kernel): report TIME logical type in cursor.description - #1084
Open
atharva18-hue wants to merge 1 commit into
Open
atharva18-hue wants to merge 1 commit into
atharva18-hue wants to merge 1 commit into
Conversation
DATATYPE-043: the Thrift SqlName remap covered only variant/geometry/geography, so TIME columns reported 'string'; the kernel type_mapping allow-list likewise omitted TIME, so SEA reported the raw Arrow spelling 'time64[ns]'. Add 'time' to both, map Arrow time32/time64 to the new SqlType.TIME, and honour a declared precision (TIME(6)) on either path. DATATYPE-044: the same remaps preserve the result-schema TIME logical type for NULL-only columns and zero-row results (including empty SEA manifests whose physical schema is Utf8). Fixes databricks#1075 Signed-off-by: Atharva Chavhan <atharvachavhan18@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1075 (DATATYPE-043, DATATYPE-044).
Problem
cursor.descriptionreported the wrong type for TIME result columns:'string'at every precision — theSpark:DataType:SqlNamelogical-type remap covered only variant/geometry/geography.'time64[ns]'— thedatabricks.type_nameallow-list intype_mapping.pyomitted TIME.'string'on Thrift;'time64[ns]'/'string'on SEA, where the empty manifest's physical schema is UTF-8).Change
thrift_backend.py: addtimeto the SqlName remap regex, soTIME(0)/TIME(3)/TIME(6)report astime(same mechanism as variant/geometry/geography).kernel/type_mapping.py: add"time"to thedatabricks.type_nameallow-list (tolerating a declared precision, e.g.TIME(6)), and map Arrowtime32/time64to the newSqlType.TIME. The metadata path is what preserves TIME for empty-result manifests whose physical schema is Utf8; the Arrow-shape path covers NULL-only columns with no metadata. Precision staysNone, matching the Thrift backend.Tests
test_col_to_descriptionandtest_hive_schema_to_description(Thrift), and intest_kernel_type_mapping.py(Arrow-shape mapping, metadata recovery incl. the empty-manifest Utf8 shape andTIME(6), and the precision-Nonecontract for TIME).pytest tests/unit/test_thrift_backend.py99 passed, 82 skipped (pyarrow-gated; pyarrow cannot import in this sandbox — it needs NumPy >= 2.0 and the sandbox has Debian numpy 1.26.4). The mapping logic was verified directly without pyarrow (29 checks: all precisions, NULL-only / zero-row shapes, fallbacks preserved).tests/unit/test_kernel_type_mapping.pyfails collection in this sandbox for the same pre-existing pyarrow/numpy reason (verified identical on pristine main) — the new tests in it will run in CI.test_time_type_value_and_precision,test_null_time_and_zero_row_time_metadatain databricks-driver-test#2321) needs a live Databricks workspace, which I don't have — those tests are the tripwire for this fix.