Skip to content

Commit cc57a9a

Browse files
committed
[SPARK-52449] Make datatypes for Expression.Literal.Map/Expression.Literal.Array optional
1 parent d88298a commit cc57a9a

File tree

6 files changed

+384
-143
lines changed

6 files changed

+384
-143
lines changed

python/pyspark/sql/connect/proto/expressions_pb2.py

Lines changed: 58 additions & 58 deletions
Large diffs are not rendered by default.

python/pyspark/sql/connect/proto/expressions_pb2.pyi

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,10 @@ class Expression(google.protobuf.message.Message):
475475
ELEMENT_TYPE_FIELD_NUMBER: builtins.int
476476
ELEMENTS_FIELD_NUMBER: builtins.int
477477
@property
478-
def element_type(self) -> pyspark.sql.connect.proto.types_pb2.DataType: ...
478+
def element_type(self) -> pyspark.sql.connect.proto.types_pb2.DataType:
479+
"""(Optional) The element type of the array. Only need to set this when the elements is
480+
empty since now we support infer the element type from the elements.
481+
"""
479482
@property
480483
def elements(
481484
self,
@@ -489,14 +492,25 @@ class Expression(google.protobuf.message.Message):
489492
elements: collections.abc.Iterable[global___Expression.Literal] | None = ...,
490493
) -> None: ...
491494
def HasField(
492-
self, field_name: typing_extensions.Literal["element_type", b"element_type"]
495+
self,
496+
field_name: typing_extensions.Literal[
497+
"_element_type", b"_element_type", "element_type", b"element_type"
498+
],
493499
) -> builtins.bool: ...
494500
def ClearField(
495501
self,
496502
field_name: typing_extensions.Literal[
497-
"element_type", b"element_type", "elements", b"elements"
503+
"_element_type",
504+
b"_element_type",
505+
"element_type",
506+
b"element_type",
507+
"elements",
508+
b"elements",
498509
],
499510
) -> None: ...
511+
def WhichOneof(
512+
self, oneof_group: typing_extensions.Literal["_element_type", b"_element_type"]
513+
) -> typing_extensions.Literal["element_type"] | None: ...
500514

501515
class Map(google.protobuf.message.Message):
502516
DESCRIPTOR: google.protobuf.descriptor.Descriptor
@@ -506,9 +520,15 @@ class Expression(google.protobuf.message.Message):
506520
KEYS_FIELD_NUMBER: builtins.int
507521
VALUES_FIELD_NUMBER: builtins.int
508522
@property
509-
def key_type(self) -> pyspark.sql.connect.proto.types_pb2.DataType: ...
523+
def key_type(self) -> pyspark.sql.connect.proto.types_pb2.DataType:
524+
"""(Optional) The key type of the map. Only need to set this when the keys is
525+
empty since now we support infer the key type from the keys.
526+
"""
510527
@property
511-
def value_type(self) -> pyspark.sql.connect.proto.types_pb2.DataType: ...
528+
def value_type(self) -> pyspark.sql.connect.proto.types_pb2.DataType:
529+
"""(Optional) The value type of the map. Only need to set this when the values is
530+
empty since now we support infer the value type from the values.
531+
"""
512532
@property
513533
def keys(
514534
self,
@@ -532,12 +552,23 @@ class Expression(google.protobuf.message.Message):
532552
def HasField(
533553
self,
534554
field_name: typing_extensions.Literal[
535-
"key_type", b"key_type", "value_type", b"value_type"
555+
"_key_type",
556+
b"_key_type",
557+
"_value_type",
558+
b"_value_type",
559+
"key_type",
560+
b"key_type",
561+
"value_type",
562+
b"value_type",
536563
],
537564
) -> builtins.bool: ...
538565
def ClearField(
539566
self,
540567
field_name: typing_extensions.Literal[
568+
"_key_type",
569+
b"_key_type",
570+
"_value_type",
571+
b"_value_type",
541572
"key_type",
542573
b"key_type",
543574
"keys",
@@ -548,6 +579,14 @@ class Expression(google.protobuf.message.Message):
548579
b"values",
549580
],
550581
) -> None: ...
582+
@typing.overload
583+
def WhichOneof(
584+
self, oneof_group: typing_extensions.Literal["_key_type", b"_key_type"]
585+
) -> typing_extensions.Literal["key_type"] | None: ...
586+
@typing.overload
587+
def WhichOneof(
588+
self, oneof_group: typing_extensions.Literal["_value_type", b"_value_type"]
589+
) -> typing_extensions.Literal["value_type"] | None: ...
551590

552591
class Struct(google.protobuf.message.Message):
553592
DESCRIPTOR: google.protobuf.descriptor.Descriptor

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,19 @@ message Expression {
214214
}
215215

216216
message Array {
217-
DataType element_type = 1;
217+
// (Optional) The element type of the array. Only need to set this when the elements are
218+
// empty, since spark 4.1+ supports inferring the element type from the elements.
219+
optional DataType element_type = 1;
218220
repeated Literal elements = 2;
219221
}
220222

221223
message Map {
222-
DataType key_type = 1;
223-
DataType value_type = 2;
224+
// (Optional) The key type of the map. Only need to set this when the keys are
225+
// empty, since spark 4.1+ supports inferring the key type from the keys
226+
optional DataType key_type = 1;
227+
// (Optional) The value type of the map. Only need to set this when the values are
228+
// empty, since spark 4.1+ supports inferring the value type from the values.
229+
optional DataType value_type = 2;
224230
repeated Literal keys = 3;
225231
repeated Literal values = 4;
226232
}

0 commit comments

Comments
 (0)