Uh oh!
There was an error while loading. Please reload this page.
[SPARK-57160][CONNECT] Add Spark Connect protocol support for nanosecond-capable timestamp types and literals - #56909
Closed
MaxGekk wants to merge 1 commit into
Closed
[SPARK-57160][CONNECT] Add Spark Connect protocol support for nanosecond-capable timestamp types and literals#56909MaxGekk wants to merge 1 commit into
MaxGekk wants to merge 1 commit into
Conversation
…ond-capable timestamp types and literals Extend the Spark Connect protobuf protocol to represent TimestampNTZNanos(p) and TimestampLTZNanos(p) (p in [7, 9]) both as data types and as literal values, and regenerate the Python stubs.
yadavay-amzn
approved these changes
Jun 30, 2026
yadavay-amzn
left a comment
Contributor
There was a problem hiding this comment.
LGTM with a small nit
Clean, well-scoped protocol addition - field numbers are allocated correctly and the encoding faithfully mirrors the Catalyst value type.
Nit: the DataType TimestampNTZNanos/TimestampLTZNanos messages don't state the omitted-precision default, while the literal arms do ("defaults to 9"). Since the type defaults to 9 too (TimestampNTZNanosType.apply()), mirroring that one-liner would keep them symmetric.
What I verified:
- Field numbers append past the literal oneof's
reserved 27, 28(Geometry/Geography) and the DataType oneof's used range - additive and wire-compatible, no reuse or renumber. epoch_micros+nanos_within_microin[0, 999]matches CatalystTimestampNanosVal(epochMicros,MAX_NANOS_WITHIN_MICRO = 999); the two-component encoding matches why a single int64 of nanos can't span the year range.- Precision 7/8/9 and default 9 match
Timestamp{NTZ,LTZ}NanosType(MIN_PRECISION/MAX_PRECISION/DEFAULT_PRECISION). - NTZ and LTZ as separate kinds/arms is consistent with the existing
timestampvstimestamp_ntzsplit.
zhengruifeng
approved these changes
Jul 1, 2026
MaxGekk
commented
Jul 1, 2026
MemberAuthor
Merging to master/4.x. Thank you, @yadavay-amzn and @zhengruifeng for review. |
MaxGekk added a commit
that referenced
this pull request
Jul 1, 2026
…ond-capable timestamp types and literals ### What changes were proposed in this pull request? This PR adds the Spark Connect protocol surface for nanosecond timestamps so they can travel over the wire, both as types and as literals. There is no behavior change yet -- the converters that consume these messages land in follow-up sub-tasks of SPARK-56822. - `types.proto`: two new data-type kinds, `TimestampNTZNanos` and `TimestampLTZNanos`, each with an optional `precision` (7..9). - `expressions.proto`: matching literal arms that carry the value as `epoch_micros` + `nanos_within_micro` (0..999) plus an optional `precision`. Two components are used instead of a single int64 of nanoseconds because nanoseconds-since-epoch cannot cover the full `0001..9999` year range; this mirrors the Catalyst value `TimestampNanosVal`. - Regenerated the Python stubs under `python/pyspark/sql/connect/proto/`. NTZ and LTZ are kept as separate kinds/arms (like `timestamp` vs `timestamp_ntz`), and non-negative fields use `uint32`. ### Why are the changes needed? Today the Connect `DataType` message has only microsecond timestamp kinds (`timestamp`, `timestamp_ntz`) with no precision field, and the `Expression.Literal` message encodes timestamp literals as a single int64 of microseconds. There is no way to express a nanosecond-capable timestamp type or a sub-microsecond literal over the wire, so no Connect client/server path can carry the new types. The protocol must be extended before any converter, Arrow, or client work can proceed. ### Does this PR introduce _any_ user-facing change? No. This only adds protobuf message definitions; the new types remain gated behind `spark.sql.timestampNanosTypes.enabled` once the consuming paths are implemented. ### How was this patch tested? - `buf build` / `buf lint` succeed for the modified protos (field numbers appended, no reuse/renumber). - `./dev/connect-gen-protos.sh` regenerates the committed Python stubs; `./dev/check-protos.py` reports no drift (pyspark-connect and pyspark-streaming: SUCCESS). - `build/sbt "connect/testOnly *LiteralExpressionProtoConverterSuite"` (44 tests) and `build/sbt "connect-client-jvm/testOnly *ColumnNodeToProtoConverterSuite"` (18 tests) pass, confirming the additive proto fields do not break existing proto plumbing. No functional tests in this PR (there are no consumers of the new fields yet); behavior is covered by the converter and end-to-end sub-tasks. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Cursor (Claude Opus 4.8) Closes#56909 from MaxGekk/nanos-proto. Authored-by: Maxim Gekk <max.gekk@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com> (cherry picked from commit bc72d93) Signed-off-by: Max Gekk <max.gekk@gmail.com>
MaxGekk
commented
Jul 1, 2026
MemberAuthor
dongjoon-hyun added a commit
to apache/spark-connect-swift
that referenced
this pull request
Aug 7, 2026
…th `branch-4.3 (2026-08-07)` ### What changes were proposed in this pull request? This PR updates the `Spark Connect`-generated Swift source code by regenerating with `branch-4.3 (2026-08-07)` - apache/spark#56300 - apache/spark#56909 - apache/spark#57412 ### Why are the changes needed? To keep the generated Swift source code in sync with Apache Spark `branch-4.3` protobuf definitions. ``` $ git clone -b branch-4.3 https://github.com/apache/spark.git $ cd spark/sql/connect/common/src/main/protobuf/ $ protoc --swift_out=. spark/connect/*.proto $ protoc --grpc-swift_out=. spark/connect/*.proto // Remove empty GRPC files $ cd spark/connect $ grep 'This file contained no services' * | awk -F: '{print $1}' | xargs rm ``` ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Fable 5 Closes#490 from dongjoon-hyun/SPARK-58652. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
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 freeto 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 adds the Spark Connect protocol surface for nanosecond timestamps so they can travel over the wire, both as types and as literals. There is no behavior change yet -- the converters that consume these messages land in follow-up sub-tasks of SPARK-56822.
types.proto: two new data-type kinds,TimestampNTZNanosandTimestampLTZNanos, each with an optionalprecision(7..9).expressions.proto: matching literal arms that carry the value asepoch_micros+nanos_within_micro(0..999) plus an optionalprecision. Two components are used instead of a single int64 of nanoseconds because nanoseconds-since-epoch cannot cover the full0001..9999year range; this mirrors the Catalyst valueTimestampNanosVal.python/pyspark/sql/connect/proto/.NTZ and LTZ are kept as separate kinds/arms (like
timestampvstimestamp_ntz), and non-negative fields useuint32.Why are the changes needed?
Today the Connect
DataTypemessage has only microsecond timestamp kinds (timestamp,timestamp_ntz) with no precision field, and theExpression.Literalmessage encodes timestamp literals as a single int64 of microseconds. There is no way to express a nanosecond-capable timestamp type or a sub-microsecond literal over the wire, so no Connect client/server path can carry the new types. The protocol must be extended before any converter, Arrow, or client work can proceed.Does this PR introduce any user-facing change?
No. This only adds protobuf message definitions; the new types remain gated behind
spark.sql.timestampNanosTypes.enabledonce the consuming paths are implemented.How was this patch tested?
buf build/buf lintsucceed for the modified protos (field numbers appended, no reuse/renumber)../dev/connect-gen-protos.shregenerates the committed Python stubs;./dev/check-protos.pyreports no drift (pyspark-connect and pyspark-streaming: SUCCESS).build/sbt "connect/testOnly *LiteralExpressionProtoConverterSuite"(44 tests) andbuild/sbt "connect-client-jvm/testOnly *ColumnNodeToProtoConverterSuite"(18 tests) pass, confirming the additive proto fields do not break existing proto plumbing.No functional tests in this PR (there are no consumers of the new fields yet); behavior is covered by the converter and end-to-end sub-tasks.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.8)