From 35b2d15e8a73de913fad3734843620c47f0b7e40 Mon Sep 17 00:00:00 2001 From: Huan Chen Date: Thu, 22 Aug 2024 17:52:09 +0000 Subject: [PATCH 1/2] fix: struct field non-nullable type issue. --- bigframes/core/compile/scalar_op_compiler.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bigframes/core/compile/scalar_op_compiler.py b/bigframes/core/compile/scalar_op_compiler.py index e70c49e337..ad54314ab9 100644 --- a/bigframes/core/compile/scalar_op_compiler.py +++ b/bigframes/core/compile/scalar_op_compiler.py @@ -754,7 +754,9 @@ def struct_field_op_impl(x: ibis_types.Value, op: ops.StructFieldOp): name = op.name_or_index else: name = struct_value.names[op.name_or_index] - return struct_value[name].name(name) + + result = struct_value[name].name(name) + return result.cast(result.type()(nullable=True)) def numeric_to_datetime(x: ibis_types.Value, unit: str) -> ibis_types.TimestampValue: From 80481241ebc7502ad0d22cb53d7d2915cb924a3e Mon Sep 17 00:00:00 2001 From: Huan Chen Date: Thu, 22 Aug 2024 17:58:40 +0000 Subject: [PATCH 2/2] update logic --- bigframes/core/compile/scalar_op_compiler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bigframes/core/compile/scalar_op_compiler.py b/bigframes/core/compile/scalar_op_compiler.py index ad54314ab9..4818d3ca76 100644 --- a/bigframes/core/compile/scalar_op_compiler.py +++ b/bigframes/core/compile/scalar_op_compiler.py @@ -755,8 +755,8 @@ def struct_field_op_impl(x: ibis_types.Value, op: ops.StructFieldOp): else: name = struct_value.names[op.name_or_index] - result = struct_value[name].name(name) - return result.cast(result.type()(nullable=True)) + result = struct_value[name] + return result.cast(result.type()(nullable=True)).name(name) def numeric_to_datetime(x: ibis_types.Value, unit: str) -> ibis_types.TimestampValue: