Commit bc72d93
committed
[SPARK-57160][CONNECT] Add Spark Connect protocol support for nanosecond-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>1 parent df728ff commit bc72d93
6 files changed
Lines changed: 389 additions & 125 deletions
File tree
- python/pyspark/sql/connect/proto
- sql/connect/common/src/main/protobuf/spark/connect
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
729 | 729 | | |
730 | 730 | | |
731 | 731 | | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
732 | 825 | | |
733 | 826 | | |
734 | 827 | | |
| |||
751 | 844 | | |
752 | 845 | | |
753 | 846 | | |
| 847 | + | |
| 848 | + | |
754 | 849 | | |
755 | 850 | | |
756 | 851 | | |
| |||
786 | 881 | | |
787 | 882 | | |
788 | 883 | | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
789 | 891 | | |
790 | 892 | | |
791 | 893 | | |
| |||
818 | 920 | | |
819 | 921 | | |
820 | 922 | | |
| 923 | + | |
| 924 | + | |
821 | 925 | | |
822 | 926 | | |
823 | 927 | | |
| |||
867 | 971 | | |
868 | 972 | | |
869 | 973 | | |
| 974 | + | |
| 975 | + | |
870 | 976 | | |
871 | 977 | | |
| 978 | + | |
| 979 | + | |
872 | 980 | | |
873 | 981 | | |
874 | 982 | | |
| |||
920 | 1028 | | |
921 | 1029 | | |
922 | 1030 | | |
| 1031 | + | |
| 1032 | + | |
923 | 1033 | | |
924 | 1034 | | |
| 1035 | + | |
| 1036 | + | |
925 | 1037 | | |
926 | 1038 | | |
927 | 1039 | | |
| |||
952 | 1064 | | |
953 | 1065 | | |
954 | 1066 | | |
| 1067 | + | |
| 1068 | + | |
955 | 1069 | | |
956 | 1070 | | |
957 | 1071 | | |
| |||
0 commit comments