Skip to content

Commit

Permalink
.make + bool
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLolthe1st committed Dec 20, 2023
1 parent 026d2e1 commit 62c4d4c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
35 changes: 25 additions & 10 deletions ydb/library/yql/providers/yt/comp_nodes/dq/arrow_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,25 @@ template<typename T, bool IsDictionary>
arrow::Datum NumericConverterImpl(NUdf::IArrayBuilder* builder, std::shared_ptr<arrow::ArrayData> block) {
if constexpr (!IsDictionary) {
typename ::arrow::TypeTraits<T>::ArrayType val(block); // checking for compatibility
arrow::UInt32Array w;
if (val.null_count()) {
for (i64 i = 0; i < block->length; ++i) {
if (val.IsNull(i)) {
builder->Add(NUdf::TBlockItem{});
} else {
builder->Add(NUdf::TBlockItem(val.Value(i)));
if constexpr (std::is_same_v<decltype(val.Value(i)), bool>) {
builder->Add(NUdf::TBlockItem((ui8)val.Value(i)));
} else {
builder->Add(NUdf::TBlockItem(val.Value(i)));
}
}
}
} else {
for (i64 i = 0; i < block->length; ++i) {
builder->Add(NUdf::TBlockItem(val.Value(i)));
if constexpr (std::is_same_v<decltype(val.Value(i)), bool>) {
builder->Add(NUdf::TBlockItem((ui8)val.Value(i)));
} else {
builder->Add(NUdf::TBlockItem(val.Value(i)));
}
}
}
return builder->Build(false);
Expand All @@ -56,12 +63,20 @@ arrow::Datum NumericConverterImpl(NUdf::IArrayBuilder* builder, std::shared_ptr<
if (dict.IsNull(i)) {
builder->Add(NUdf::TBlockItem{});
} else {
builder->Add(NUdf::TBlockItem(val.Value(data[i])));
if constexpr (std::is_same_v<decltype(val.Value(data[i])), bool>) {
builder->Add(NUdf::TBlockItem((ui8)val.Value(data[i])));
} else {
builder->Add(NUdf::TBlockItem(val.Value(data[i])));
}
}
}
} else {
for (i64 i = 0; i < block->length; ++i) {
builder->Add(NUdf::TBlockItem(val.Value(data[i])));
if constexpr (std::is_same_v<decltype(val.Value(data[i])), bool>) {
builder->Add(NUdf::TBlockItem((ui8)val.Value(data[i])));
} else {
builder->Add(NUdf::TBlockItem(val.Value(data[i])));
}
}
}
return builder->Build(false);
Expand Down Expand Up @@ -402,6 +417,7 @@ class TPrimitiveColumnConverter {
public:
TPrimitiveColumnConverter(TYtColumnConverterSettings& settings) : Settings_(settings) {
switch (Settings_.ArrowType->id()) {
case arrow::Type::BOOL: PrimitiveConverterImpl_ = GEN_TYPE(Boolean); break;
case arrow::Type::INT8: PrimitiveConverterImpl_ = GEN_TYPE(Int8); break;
case arrow::Type::UINT8: PrimitiveConverterImpl_ = GEN_TYPE(UInt8); break;
case arrow::Type::INT16: PrimitiveConverterImpl_ = GEN_TYPE(Int16); break;
Expand Down Expand Up @@ -510,8 +526,7 @@ class TYtColumnConverter final : public IYtColumnConverter {
: Settings_(std::move(settings))
, DictYsonConverter_(Settings_)
, YsonConverter_(Settings_)
, DictPrimitiveConverter_(Settings_)
, PrimitiveConverter_(Settings_) {}
, DictPrimitiveConverter_(Settings_) {}

arrow::Datum Convert(std::shared_ptr<arrow::ArrayData> block) override {
if (arrow::Type::DICTIONARY == block->type->id()) {
Expand All @@ -522,9 +537,10 @@ class TYtColumnConverter final : public IYtColumnConverter {
}
} else {
if (block->type->Equals(Settings_.ArrowType)) {
return PrimitiveConverter_.Convert(block);
} else {
return block;
} else {
YQL_ENSURE(arrow::Type::BINARY == block->type->id());
return YsonConverter_.Convert(block);
}
}
}
Expand All @@ -533,7 +549,6 @@ class TYtColumnConverter final : public IYtColumnConverter {
TYtYsonColumnConverter<Native, IsTopOptional, true> DictYsonConverter_;
TYtYsonColumnConverter<Native, IsTopOptional, false> YsonConverter_;
TPrimitiveColumnConverter<true> DictPrimitiveConverter_;
TPrimitiveColumnConverter<false> PrimitiveConverter_;
};

TYtColumnConverterSettings::TYtColumnConverterSettings(NKikimr::NMiniKQL::TType* type, const NUdf::IPgBuilder* pgBuilder, arrow::MemoryPool& pool, bool isNative)
Expand Down
3 changes: 2 additions & 1 deletion ydb/library/yql/providers/yt/comp_nodes/dq/ya.make
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
LIBRARY()

PEERDIR(
ydb/library/yql/minikql
ydb/library/yql/minikql/computation/llvm
ydb/library/yql/providers/yt/comp_nodes
ydb/library/yql/providers/yt/codec
ydb/library/yql/providers/common/codec
ydb/core/formats/arrow
yt/cpp/mapreduce/interface
yt/cpp/mapreduce/common
library/cpp/yson/node
Expand All @@ -27,6 +27,7 @@ IF(LINUX)
)

SRCS(
arrow_converter.cpp
stream_decoder.cpp
dq_yt_rpc_reader.cpp
dq_yt_rpc_helpers.cpp
Expand Down

0 comments on commit 62c4d4c

Please sign in to comment.