Skip to content

Commit 634b4ce

Browse files
committed
[SPARK-52770][CONNECT] Support TIME type in connect proto
1 parent 6c6ca1f commit 634b4ce

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

sql/connect/common/src/main/protobuf/spark/connect/types.proto

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ message DataType {
6969

7070
// UnparsedDataType
7171
Unparsed unparsed = 24;
72+
73+
Time time = 28;
7274
}
7375

7476
// Reserved for geometry and geography types
@@ -127,6 +129,11 @@ message DataType {
127129
uint32 type_variation_reference = 1;
128130
}
129131

132+
message Time {
133+
int32 precision = 1;
134+
uint32 type_variation_reference = 2;
135+
}
136+
130137
message CalendarInterval {
131138
uint32 type_variation_reference = 1;
132139
}

sql/connect/common/src/main/scala/org/apache/spark/sql/connect/common/DataTypeProtoConverter.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ object DataTypeProtoConverter {
5353
case proto.DataType.KindCase.DATE => DateType
5454
case proto.DataType.KindCase.TIMESTAMP => TimestampType
5555
case proto.DataType.KindCase.TIMESTAMP_NTZ => TimestampNTZType
56+
case proto.DataType.KindCase.TIME => TimeType(t.getTime.getPrecision)
5657

5758
case proto.DataType.KindCase.CALENDAR_INTERVAL => CalendarIntervalType
5859
case proto.DataType.KindCase.YEAR_MONTH_INTERVAL =>
@@ -204,6 +205,12 @@ object DataTypeProtoConverter {
204205

205206
case TimestampNTZType => ProtoDataTypes.TimestampNTZType
206207

208+
case TimeType(precision) =>
209+
proto.DataType
210+
.newBuilder()
211+
.setTime(proto.DataType.Time.newBuilder().setPrecision(precision).build())
212+
.build()
213+
207214
case CalendarIntervalType => ProtoDataTypes.CalendarIntervalType
208215

209216
case YearMonthIntervalType(startField, endField) =>

0 commit comments

Comments
 (0)