Skip to content

Commit 62c4d4c

Browse files
committed
.make + bool
1 parent 026d2e1 commit 62c4d4c

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

ydb/library/yql/providers/yt/comp_nodes/dq/arrow_converter.cpp

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,25 @@ template<typename T, bool IsDictionary>
3232
arrow::Datum NumericConverterImpl(NUdf::IArrayBuilder* builder, std::shared_ptr<arrow::ArrayData> block) {
3333
if constexpr (!IsDictionary) {
3434
typename ::arrow::TypeTraits<T>::ArrayType val(block); // checking for compatibility
35-
arrow::UInt32Array w;
3635
if (val.null_count()) {
3736
for (i64 i = 0; i < block->length; ++i) {
3837
if (val.IsNull(i)) {
3938
builder->Add(NUdf::TBlockItem{});
4039
} else {
41-
builder->Add(NUdf::TBlockItem(val.Value(i)));
40+
if constexpr (std::is_same_v<decltype(val.Value(i)), bool>) {
41+
builder->Add(NUdf::TBlockItem((ui8)val.Value(i)));
42+
} else {
43+
builder->Add(NUdf::TBlockItem(val.Value(i)));
44+
}
4245
}
4346
}
4447
} else {
4548
for (i64 i = 0; i < block->length; ++i) {
46-
builder->Add(NUdf::TBlockItem(val.Value(i)));
49+
if constexpr (std::is_same_v<decltype(val.Value(i)), bool>) {
50+
builder->Add(NUdf::TBlockItem((ui8)val.Value(i)));
51+
} else {
52+
builder->Add(NUdf::TBlockItem(val.Value(i)));
53+
}
4754
}
4855
}
4956
return builder->Build(false);
@@ -56,12 +63,20 @@ arrow::Datum NumericConverterImpl(NUdf::IArrayBuilder* builder, std::shared_ptr<
5663
if (dict.IsNull(i)) {
5764
builder->Add(NUdf::TBlockItem{});
5865
} else {
59-
builder->Add(NUdf::TBlockItem(val.Value(data[i])));
66+
if constexpr (std::is_same_v<decltype(val.Value(data[i])), bool>) {
67+
builder->Add(NUdf::TBlockItem((ui8)val.Value(data[i])));
68+
} else {
69+
builder->Add(NUdf::TBlockItem(val.Value(data[i])));
70+
}
6071
}
6172
}
6273
} else {
6374
for (i64 i = 0; i < block->length; ++i) {
64-
builder->Add(NUdf::TBlockItem(val.Value(data[i])));
75+
if constexpr (std::is_same_v<decltype(val.Value(data[i])), bool>) {
76+
builder->Add(NUdf::TBlockItem((ui8)val.Value(data[i])));
77+
} else {
78+
builder->Add(NUdf::TBlockItem(val.Value(data[i])));
79+
}
6580
}
6681
}
6782
return builder->Build(false);
@@ -402,6 +417,7 @@ class TPrimitiveColumnConverter {
402417
public:
403418
TPrimitiveColumnConverter(TYtColumnConverterSettings& settings) : Settings_(settings) {
404419
switch (Settings_.ArrowType->id()) {
420+
case arrow::Type::BOOL: PrimitiveConverterImpl_ = GEN_TYPE(Boolean); break;
405421
case arrow::Type::INT8: PrimitiveConverterImpl_ = GEN_TYPE(Int8); break;
406422
case arrow::Type::UINT8: PrimitiveConverterImpl_ = GEN_TYPE(UInt8); break;
407423
case arrow::Type::INT16: PrimitiveConverterImpl_ = GEN_TYPE(Int16); break;
@@ -510,8 +526,7 @@ class TYtColumnConverter final : public IYtColumnConverter {
510526
: Settings_(std::move(settings))
511527
, DictYsonConverter_(Settings_)
512528
, YsonConverter_(Settings_)
513-
, DictPrimitiveConverter_(Settings_)
514-
, PrimitiveConverter_(Settings_) {}
529+
, DictPrimitiveConverter_(Settings_) {}
515530

516531
arrow::Datum Convert(std::shared_ptr<arrow::ArrayData> block) override {
517532
if (arrow::Type::DICTIONARY == block->type->id()) {
@@ -522,9 +537,10 @@ class TYtColumnConverter final : public IYtColumnConverter {
522537
}
523538
} else {
524539
if (block->type->Equals(Settings_.ArrowType)) {
525-
return PrimitiveConverter_.Convert(block);
526-
} else {
527540
return block;
541+
} else {
542+
YQL_ENSURE(arrow::Type::BINARY == block->type->id());
543+
return YsonConverter_.Convert(block);
528544
}
529545
}
530546
}
@@ -533,7 +549,6 @@ class TYtColumnConverter final : public IYtColumnConverter {
533549
TYtYsonColumnConverter<Native, IsTopOptional, true> DictYsonConverter_;
534550
TYtYsonColumnConverter<Native, IsTopOptional, false> YsonConverter_;
535551
TPrimitiveColumnConverter<true> DictPrimitiveConverter_;
536-
TPrimitiveColumnConverter<false> PrimitiveConverter_;
537552
};
538553

539554
TYtColumnConverterSettings::TYtColumnConverterSettings(NKikimr::NMiniKQL::TType* type, const NUdf::IPgBuilder* pgBuilder, arrow::MemoryPool& pool, bool isNative)

ydb/library/yql/providers/yt/comp_nodes/dq/ya.make

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
LIBRARY()
22

33
PEERDIR(
4+
ydb/library/yql/minikql
45
ydb/library/yql/minikql/computation/llvm
56
ydb/library/yql/providers/yt/comp_nodes
67
ydb/library/yql/providers/yt/codec
78
ydb/library/yql/providers/common/codec
8-
ydb/core/formats/arrow
99
yt/cpp/mapreduce/interface
1010
yt/cpp/mapreduce/common
1111
library/cpp/yson/node
@@ -27,6 +27,7 @@ IF(LINUX)
2727
)
2828

2929
SRCS(
30+
arrow_converter.cpp
3031
stream_decoder.cpp
3132
dq_yt_rpc_reader.cpp
3233
dq_yt_rpc_helpers.cpp

0 commit comments

Comments
 (0)