@@ -814,6 +814,27 @@ NUdf::TUnboxedValue FromPyDict(
814
814
throw yexception () << " Can't cast " << PyObjectRepr (value) << " to dict." ;
815
815
}
816
816
817
+ TPyObjectPtr ToPyNull (
818
+ const TPyCastContext::TPtr& ctx,
819
+ const NUdf::TType* type,
820
+ const NUdf::TUnboxedValuePod& value)
821
+ {
822
+ if (!value.HasValue ()) {
823
+ return TPyObjectPtr (Py_None, TPyObjectPtr::ADD_REF);
824
+ }
825
+ throw yexception () << " Value is not null" ;
826
+ }
827
+
828
+ NUdf::TUnboxedValue FromPyNull (
829
+ const TPyCastContext::TPtr& ctx,
830
+ const NUdf::TType* type, PyObject* value)
831
+ {
832
+ if (value == Py_None) {
833
+ return NYql::NUdf::TUnboxedValuePod ();
834
+ }
835
+ throw yexception () << " Can't cast " << PyObjectRepr (value) << " to null." ;
836
+ }
837
+
817
838
} // namespace
818
839
819
840
TPyObjectPtr ToPyObject (
@@ -832,6 +853,7 @@ TPyObjectPtr ToPyObject(
832
853
case NUdf::ETypeKind::Void: return ToPyVoid (ctx, type, value);
833
854
case NUdf::ETypeKind::Stream: return ToPyStream (ctx, type, value);
834
855
case NUdf::ETypeKind::Variant: return ToPyVariant (ctx, type, value);
856
+ case NUdf::ETypeKind::Null: return ToPyNull (ctx, type, value);
835
857
default : {
836
858
::TStringBuilder sb;
837
859
sb << " Failed to export: " ;
@@ -857,6 +879,7 @@ NUdf::TUnboxedValue FromPyObject(
857
879
case NUdf::ETypeKind::Void: return FromPyVoid (ctx, type, value);
858
880
case NUdf::ETypeKind::Stream: return FromPyStream (ctx, type, TPyObjectPtr (value, TPyObjectPtr::ADD_REF), nullptr , nullptr , nullptr );
859
881
case NUdf::ETypeKind::Variant: return FromPyVariant (ctx, type, value);
882
+ case NUdf::ETypeKind::Null: return FromPyNull (ctx, type, value);
860
883
default : {
861
884
::TStringBuilder sb;
862
885
sb << " Failed to import: " ;
0 commit comments