diff options
author | atarasov5 <[email protected]> | 2025-02-10 10:32:55 +0300 |
---|---|---|
committer | atarasov5 <[email protected]> | 2025-02-10 11:19:12 +0300 |
commit | bbe71b332b223c20740308be5a9c2ea1431f1ff0 (patch) | |
tree | 26f167da71bfa8ab54db753d8236e0ba82b1f461 /yql/essentials/minikql/computation/mkql_block_impl.cpp | |
parent | f374c32c8923c81c28d12b0d349770637efe563f (diff) |
YQL-19535: Fix wrong scalar conversion
commit_hash:997d731b3d106421ee68aa2e3e18f18b03ea7a66
Diffstat (limited to 'yql/essentials/minikql/computation/mkql_block_impl.cpp')
-rw-r--r-- | yql/essentials/minikql/computation/mkql_block_impl.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/yql/essentials/minikql/computation/mkql_block_impl.cpp b/yql/essentials/minikql/computation/mkql_block_impl.cpp index 2920a1ac3c3..49d52eb0b88 100644 --- a/yql/essentials/minikql/computation/mkql_block_impl.cpp +++ b/yql/essentials/minikql/computation/mkql_block_impl.cpp @@ -114,8 +114,14 @@ arrow::Datum DoConvertScalar(TType* type, const T& value, arrow::MemoryPool& poo const auto& str = value.AsStringRef(); std::shared_ptr<arrow::Buffer> buffer(ARROW_RESULT(arrow::AllocateBuffer(str.Size(), &pool))); std::memcpy(buffer->mutable_data(), str.Data(), str.Size()); - auto type = (slot == NUdf::EDataSlot::String || slot == NUdf::EDataSlot::Yson || slot == NUdf::EDataSlot::JsonDocument) ? arrow::binary() : arrow::utf8(); - std::shared_ptr<arrow::Scalar> scalar = std::make_shared<arrow::BinaryScalar>(buffer, type); + std::shared_ptr<arrow::Scalar> scalar; + if (slot == NUdf::EDataSlot::String || slot == NUdf::EDataSlot::Yson || slot == NUdf::EDataSlot::JsonDocument) { + scalar = std::make_shared<arrow::BinaryScalar>(buffer, arrow::binary()); + } else { + // NOTE: Do not use |arrow::BinaryScalar| for utf8 and json types directly. + // This is necessary so that the type of the scalar is clearly preserved at runtime. + scalar = std::make_shared<arrow::StringScalar>(buffer); + } return arrow::Datum(scalar); } case NUdf::EDataSlot::TzDate: { |