aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnaury <snaury@ydb.tech>2023-06-30 10:08:19 +0300
committersnaury <snaury@ydb.tech>2023-06-30 10:08:19 +0300
commitc132b4657d034ec319b4bb63f62a923adf9d7441 (patch)
tree0d8de9424842ff9b13d10812509f408516852fa0
parent46510d6c88912219669dfe229e9f6b55603d97ca (diff)
downloadydb-c132b4657d034ec319b4bb63f62a923adf9d7441.tar.gz
Fix incorrect downcast in ReserveData for string types
-rw-r--r--ydb/core/formats/arrow/arrow_helpers.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/ydb/core/formats/arrow/arrow_helpers.cpp b/ydb/core/formats/arrow/arrow_helpers.cpp
index fbad4b2d1c..c4a86ed5f0 100644
--- a/ydb/core/formats/arrow/arrow_helpers.cpp
+++ b/ydb/core/formats/arrow/arrow_helpers.cpp
@@ -798,11 +798,12 @@ bool ArrayScalarsEqual(const std::shared_ptr<arrow::Array>& lhs, const std::shar
bool ReserveData(arrow::ArrayBuilder& builder, const size_t size) {
arrow::Status result = arrow::Status::OK();
- if (builder.type()->id() == arrow::Type::BINARY) {
- arrow::BaseBinaryBuilder<arrow::BinaryType>& bBuilder = static_cast<arrow::BaseBinaryBuilder<arrow::BinaryType>&>(builder);
- result = bBuilder.ReserveData(size);
- } else if (builder.type()->id() == arrow::Type::STRING) {
- arrow::BaseBinaryBuilder<arrow::StringType>& bBuilder = static_cast<arrow::BaseBinaryBuilder<arrow::StringType>&>(builder);
+ if (builder.type()->id() == arrow::Type::BINARY ||
+ builder.type()->id() == arrow::Type::STRING)
+ {
+ static_assert(std::is_convertible_v<arrow::StringBuilder&, arrow::BaseBinaryBuilder<arrow::BinaryType>&>,
+ "Expected StringBuilder to be BaseBinaryBuilder<BinaryType>");
+ auto& bBuilder = static_cast<arrow::BaseBinaryBuilder<arrow::BinaryType>&>(builder);
result = bBuilder.ReserveData(size);
}