[SPARK-57463][SQL] Render nanosecond-precision timestamp types in the Thrift server via the Types Framework#56519
Open
MaxGekk wants to merge 1 commit into
Open
[SPARK-57463][SQL] Render nanosecond-precision timestamp types in the Thrift server via the Types Framework#56519MaxGekk wants to merge 1 commit into
MaxGekk wants to merge 1 commit into
Conversation
… Thrift server via the Types Framework Override the Types Framework `thriftTypeName` hook in `TimestampNanosTypeApiOps` to return `STRING_TYPE` for TIMESTAMP_NTZ(p) and TIMESTAMP_LTZ(p) (p in 7-9), so these columns are usable over the Spark Thrift / JDBC server instead of failing type resolution. Values are already rendered as strings at the column precision via HiveResult.toHiveString. Adds type-mapping and end-to-end JDBC tests.
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.
What changes were proposed in this pull request?
This PR implements the Types Framework
thriftTypeNamehook for the nanosecond-capable timestamp typesTIMESTAMP_NTZ(p)andTIMESTAMP_LTZ(p)(pin 7-9), so they are usable over the Spark Thrift / JDBC server, reaching parity with the microsecondTimestampType/TimestampNTZType.SparkExecuteStatementOperationresolves a column's ThriftTTypeIdviaTypeApiOps(typ).flatMap(_.thriftTypeName).TimestampNanosTypeApiOpsdid not overrideTypeApiOps.thriftTypeName(it defaulted toNone), and the nanos types are not in thetoTTypeIdDefaultfallback, so a nanos column hitcase other => throw new IllegalArgumentException("Unrecognized type name: ...").The change overrides
thriftTypeNamein the abstract baseTimestampNanosTypeApiOps(inherited by both the NTZ and LTZ subclasses) to returnSome("STRING_TYPE"), mirroring the referenceTimeTypeApiOps:STRING_TYPEis the correct mapping becauseRowSetUtilsalready serializes these values as a string column (TStringColumn), rendered at the column precision byHiveResult.toHiveString(consistent with cast-to-string). No changes were needed inSparkExecuteStatementOperationorRowSetUtils.Note: related Hive CLI rendering through the framework is tracked separately by SPARK-57386.
Why are the changes needed?
To be able to retrieve nanosecond-precision timestamps via the Hive Thrift server. Before this change, with the preview flag enabled, such a query fails:
This is analogous to the ANSI-interval issue fixed by SPARK-35017 (
Unrecognized type name: day-time interval).Does this PR introduce any user-facing change?
Yes. After the changes, nanosecond timestamp columns are returned over JDBC as strings rendered at the column precision (the nanos types are a preview feature gated by
spark.sql.timestampNanosTypes.enabled):With the flag off (the production default), a nanos literal continues to degrade to a microsecond timestamp, unchanged by this PR:
How was this patch tested?
sql/hive-thriftserver:SparkExecuteStatementOperationSuite: assertstoTTableSchemamapsTimestampNTZNanosType(p)/TimestampLTZNanosType(p)(p in 7-9) toTTypeId.STRING_TYPE.HiveThriftBinaryServerSuite: an end-to-end JDBC test that enables the flag, queries NTZ/LTZ at precisions 7-9, and asserts both the column metadata (VARCHAR/"string") and the rendered fractional digits.beeline(the before/after transcripts shown above).Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.8)