Skip to content

Commit 90f5751

Browse files
authored
fix(core): Handle empty external schema fields (#3329)
Signed-off-by: Kevin Su <[email protected]>
1 parent e8df37f commit 90f5751

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

flytekit/models/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ def from_flyte_idl(cls, proto: _types_pb2.StructuredDatasetType) -> _types_pb2.S
238238
return cls(
239239
columns=[StructuredDatasetType.DatasetColumn.from_flyte_idl(c) for c in proto.columns],
240240
format=proto.format,
241-
external_schema_type=proto.external_schema_type,
242-
external_schema_bytes=proto.external_schema_bytes,
241+
external_schema_type=proto.external_schema_type if proto.external_schema_type else None,
242+
external_schema_bytes=proto.external_schema_bytes if proto.external_schema_bytes else None,
243243
)
244244

245245

tests/flytekit/unit/types/structured_dataset/test_structured_dataset.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,3 +751,12 @@ def test_structured_dataset_pickleable():
751751
unpickled_input = pickle.loads(pickled_input)
752752

753753
assert downstream_input == unpickled_input
754+
755+
def test_optional_sd_with_serde():
756+
ctx = FlyteContext.current_context()
757+
lt_optional = TypeEngine.to_literal_type(typing.Optional[StructuredDataset])
758+
759+
lit = TypeEngine.to_literal(ctx, StructuredDataset(df), python_type=typing.Optional[StructuredDataset], expected=lt_optional)
760+
lit2 = lit.from_flyte_idl(lit.to_flyte_idl())
761+
pv = TypeEngine.to_python_value(ctx, lit2, typing.Optional[StructuredDataset])
762+
assert pv is not None

0 commit comments

Comments
 (0)