diff options
author | robot-piglet <[email protected]> | 2025-10-02 14:05:32 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-10-02 14:25:43 +0300 |
commit | 61596e93766bc22f9273810d7607a1f641d8beec (patch) | |
tree | 0c29e830d7e5c7fb447b1932158fec6591565bd6 /yql/essentials/udfs/common/python | |
parent | ea1a91993977153ce5528ce8fef162f9b1b9e366 (diff) |
Intermediate changes
commit_hash:eba9127d442dfdfe410219202e8eee1f41da3cd9
Diffstat (limited to 'yql/essentials/udfs/common/python')
5 files changed, 66 insertions, 0 deletions
diff --git a/yql/essentials/udfs/common/python/bindings/py_cast.cpp b/yql/essentials/udfs/common/python/bindings/py_cast.cpp index 79e46164989..3048f803a72 100644 --- a/yql/essentials/udfs/common/python/bindings/py_cast.cpp +++ b/yql/essentials/udfs/common/python/bindings/py_cast.cpp @@ -647,6 +647,23 @@ NUdf::TUnboxedValue FromPyData( << "Unsupported type " << typeId; } +TPyObjectPtr ToPyTagged( + const TPyCastContext::TPtr& ctx, + const NUdf::TType* type, + const NUdf::TUnboxedValuePod& value) +{ + const NUdf::TTaggedTypeInspector inspector(*ctx->PyCtx->TypeInfoHelper, type); + return ToPyObject(ctx, inspector.GetBaseType(), value); +} + +NUdf::TUnboxedValue FromPyTagged( + const TPyCastContext::TPtr& ctx, + const NUdf::TType* type, PyObject* value) +{ + const NUdf::TTaggedTypeInspector inspector(*ctx->PyCtx->TypeInfoHelper, type); + return FromPyObject(ctx, inspector.GetBaseType(), value).Release(); +} + TPyObjectPtr ToPyList( const TPyCastContext::TPtr& ctx, const NUdf::TType* type, @@ -860,6 +877,7 @@ TPyObjectPtr ToPyObject( { switch (ctx->PyCtx->TypeInfoHelper->GetTypeKind(type)) { case NUdf::ETypeKind::Data: return ToPyData(ctx, type, value); + case NUdf::ETypeKind::Tagged: return ToPyTagged(ctx, type, value); case NUdf::ETypeKind::Tuple: return ToPyTuple(ctx, type, value); case NUdf::ETypeKind::Struct: return ToPyStruct(ctx, type, value); case NUdf::ETypeKind::List: return ToPyList(ctx, type, value); @@ -886,6 +904,7 @@ NUdf::TUnboxedValue FromPyObject( { switch (ctx->PyCtx->TypeInfoHelper->GetTypeKind(type)) { case NUdf::ETypeKind::Data: return FromPyData(ctx, type, value); + case NUdf::ETypeKind::Tagged: return FromPyTagged(ctx, type, value); case NUdf::ETypeKind::Tuple: return FromPyTuple(ctx, type, value); case NUdf::ETypeKind::Struct: return FromPyStruct(ctx, type, value); case NUdf::ETypeKind::List: return FromPyList(ctx, type, value); diff --git a/yql/essentials/udfs/common/python/python3_small/test/canondata/result.json b/yql/essentials/udfs/common/python/python3_small/test/canondata/result.json index dd55da78b53..5db4c2b5055 100644 --- a/yql/essentials/udfs/common/python/python3_small/test/canondata/result.json +++ b/yql/essentials/udfs/common/python/python3_small/test/canondata/result.json @@ -57,5 +57,10 @@ "size": 9172, "uri": "https://{canondata_backend}/1130705/493ee46b1e8f2e848ab928f97913d332cb4fffc7/resource.tar.gz#test.test_Switch_/results.txt" } + ], + "test.test[Tagged]": [ + { + "uri": "file://test.test_Tagged_/results.txt" + } ] } diff --git a/yql/essentials/udfs/common/python/python3_small/test/canondata/test.test_Tagged_/results.txt b/yql/essentials/udfs/common/python/python3_small/test/canondata/test.test_Tagged_/results.txt new file mode 100644 index 00000000000..d73319e72dc --- /dev/null +++ b/yql/essentials/udfs/common/python/python3_small/test/canondata/test.test_Tagged_/results.txt @@ -0,0 +1,32 @@ +[ + { + "Write" = [ + { + "Type" = [ + "ListType"; + [ + "StructType"; + [ + [ + "column0"; + [ + "TaggedType"; + "y"; + [ + "DataType"; + "Int32" + ] + ] + ] + ] + ] + ]; + "Data" = [ + [ + "2" + ] + ] + } + ] + } +]
\ No newline at end of file diff --git a/yql/essentials/udfs/common/python/python3_small/test/cases/Tagged.in b/yql/essentials/udfs/common/python/python3_small/test/cases/Tagged.in new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/yql/essentials/udfs/common/python/python3_small/test/cases/Tagged.in diff --git a/yql/essentials/udfs/common/python/python3_small/test/cases/Tagged.sql b/yql/essentials/udfs/common/python/python3_small/test/cases/Tagged.sql new file mode 100644 index 00000000000..9a8927bec34 --- /dev/null +++ b/yql/essentials/udfs/common/python/python3_small/test/cases/Tagged.sql @@ -0,0 +1,10 @@ +$s = @@ +def f(x): + return x + 1 +@@; + +$f = Python::f(Callable<(Tagged<Int32,'x'>)->Tagged<Int32,'y'>>, $s); + +select $f(AsTagged(1,'x')); + + |