@@ -32,18 +32,25 @@ template<typename T, bool IsDictionary>
32
32
arrow::Datum NumericConverterImpl (NUdf::IArrayBuilder* builder, std::shared_ptr<arrow::ArrayData> block) {
33
33
if constexpr (!IsDictionary) {
34
34
typename ::arrow::TypeTraits<T>::ArrayType val (block); // checking for compatibility
35
- arrow::UInt32Array w;
36
35
if (val.null_count ()) {
37
36
for (i64 i = 0 ; i < block->length ; ++i) {
38
37
if (val.IsNull (i)) {
39
38
builder->Add (NUdf::TBlockItem{});
40
39
} 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
+ }
42
45
}
43
46
}
44
47
} else {
45
48
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
+ }
47
54
}
48
55
}
49
56
return builder->Build (false );
@@ -56,12 +63,20 @@ arrow::Datum NumericConverterImpl(NUdf::IArrayBuilder* builder, std::shared_ptr<
56
63
if (dict.IsNull (i)) {
57
64
builder->Add (NUdf::TBlockItem{});
58
65
} 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
+ }
60
71
}
61
72
}
62
73
} else {
63
74
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
+ }
65
80
}
66
81
}
67
82
return builder->Build (false );
@@ -402,6 +417,7 @@ class TPrimitiveColumnConverter {
402
417
public:
403
418
TPrimitiveColumnConverter (TYtColumnConverterSettings& settings) : Settings_(settings) {
404
419
switch (Settings_.ArrowType ->id ()) {
420
+ case arrow::Type::BOOL: PrimitiveConverterImpl_ = GEN_TYPE (Boolean ); break ;
405
421
case arrow::Type::INT8: PrimitiveConverterImpl_ = GEN_TYPE (Int8); break ;
406
422
case arrow::Type::UINT8: PrimitiveConverterImpl_ = GEN_TYPE (UInt8 ); break ;
407
423
case arrow::Type::INT16: PrimitiveConverterImpl_ = GEN_TYPE (Int16); break ;
@@ -510,8 +526,7 @@ class TYtColumnConverter final : public IYtColumnConverter {
510
526
: Settings_(std::move(settings))
511
527
, DictYsonConverter_(Settings_)
512
528
, YsonConverter_(Settings_)
513
- , DictPrimitiveConverter_(Settings_)
514
- , PrimitiveConverter_(Settings_) {}
529
+ , DictPrimitiveConverter_(Settings_) {}
515
530
516
531
arrow::Datum Convert (std::shared_ptr<arrow::ArrayData> block) override {
517
532
if (arrow::Type::DICTIONARY == block->type ->id ()) {
@@ -522,9 +537,10 @@ class TYtColumnConverter final : public IYtColumnConverter {
522
537
}
523
538
} else {
524
539
if (block->type ->Equals (Settings_.ArrowType )) {
525
- return PrimitiveConverter_.Convert (block);
526
- } else {
527
540
return block;
541
+ } else {
542
+ YQL_ENSURE (arrow::Type::BINARY == block->type ->id ());
543
+ return YsonConverter_.Convert (block);
528
544
}
529
545
}
530
546
}
@@ -533,7 +549,6 @@ class TYtColumnConverter final : public IYtColumnConverter {
533
549
TYtYsonColumnConverter<Native, IsTopOptional, true > DictYsonConverter_;
534
550
TYtYsonColumnConverter<Native, IsTopOptional, false > YsonConverter_;
535
551
TPrimitiveColumnConverter<true > DictPrimitiveConverter_;
536
- TPrimitiveColumnConverter<false > PrimitiveConverter_;
537
552
};
538
553
539
554
TYtColumnConverterSettings::TYtColumnConverterSettings (NKikimr::NMiniKQL::TType* type, const NUdf::IPgBuilder* pgBuilder, arrow::MemoryPool& pool, bool isNative)
0 commit comments