Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-32228 Add fixed_size_binary data type to Parquet Plugin #18888

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions plugins/parquet/parquetembed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,10 +770,17 @@ arrow::Status ParquetWriter::fieldToNode(const RtlFieldInfo *field, std::vector<
case type_unicode:
case type_varunicode:
case type_decimal:
arrowFields.push_back(std::make_shared<arrow::Field>(name.str(), arrow::utf8())); //TODO add decimal encoding
arrowFields.push_back(std::make_shared<arrow::Field>(name.str(), arrow::utf8())); // TODO: add decimal encoding
break;
case type_data:
arrowFields.push_back(std::make_shared<arrow::Field>(name.str(), arrow::large_binary()));
if (field->type->length > 0)
{
arrowFields.push_back(std::make_shared<arrow::Field>(name.str(), arrow::fixed_size_binary(field->type->length)));
}
else
{
arrowFields.push_back(std::make_shared<arrow::Field>(name.str(), arrow::large_binary()));
}
break;
case type_record:
arrowFields.push_back(std::make_shared<arrow::Field>(name.str(), makeChildRecord(field)));
Expand Down Expand Up @@ -992,20 +999,26 @@ void ParquetWriter::addFieldToBuilder(const RtlFieldInfo *field, unsigned len, c
arrow::ArrayBuilder *fieldBuilder = getFieldBuilder(field);
switch(fieldBuilder->type()->id())
{
case arrow::Type::type::STRING:
case arrow::Type::STRING:
{
arrow::StringBuilder *stringBuilder = static_cast<arrow::StringBuilder *>(fieldBuilder);
reportIfFailure(stringBuilder->Append(data, len));
break;
}
case arrow::Type::type::LARGE_BINARY:
case arrow::Type::LARGE_BINARY:
{
arrow::LargeBinaryBuilder *largeBinaryBuilder = static_cast<arrow::LargeBinaryBuilder *>(fieldBuilder);
reportIfFailure(largeBinaryBuilder->Append(data, len));
break;
}
case arrow::Type::FIXED_SIZE_BINARY:
{
arrow::FixedSizeBinaryBuilder *fixedSizeBinaryBuilder = static_cast<arrow::FixedSizeBinaryBuilder *>(fieldBuilder);
reportIfFailure(fixedSizeBinaryBuilder->Append(data));
break;
}
default:
failx("Incorrect type for String/Large_Binary addFieldToBuilder: %s", fieldBuilder->type()->ToString().c_str());
failx("Incorrect type for String/Large_Binary/Fixed_Size_Binary addFieldToBuilder: %s", fieldBuilder->type()->ToString().c_str());
}
}

Expand Down Expand Up @@ -1178,6 +1191,8 @@ std::string_view ParquetRowBuilder::getCurrView(const RtlFieldInfo *field)
return arrayVisitor->largeStringArr->GetView(currArrayIndex());
case DecimalType:
return arrayVisitor->size == 128 ? arrayVisitor->decArr->GetView(currArrayIndex()) : arrayVisitor->largeDecArr->GetView(currArrayIndex());
case FixedSizeBinaryType:
return arrayVisitor->fixedSizeBinaryArr->GetView(currArrayIndex());
default:
failx("Unimplemented Parquet type for field with name %s.", field->name);
}
Expand Down
11 changes: 10 additions & 1 deletion plugins/parquet/parquetembed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ enum ParquetArrayType
DecimalType,
ListType,
StructType,
RealType
RealType,
FixedSizeBinaryType
};

/**
Expand Down Expand Up @@ -270,6 +271,13 @@ class ParquetArrayVisitor : public arrow::ArrayVisitor
size = 8;
return arrow::Status::OK();
}
arrow::Status Visit(const arrow::FixedSizeBinaryArray &array)
ilhan2316 marked this conversation as resolved.
Show resolved Hide resolved
{
fixedSizeBinaryArr = &array;
type = FixedSizeBinaryType;
size = array.byte_width();
return arrow::Status::OK();
}
arrow::Status Visit(const arrow::StringArray &array)
{
stringArr = &array;
Expand Down Expand Up @@ -341,6 +349,7 @@ class ParquetArrayVisitor : public arrow::ArrayVisitor
const arrow::HalfFloatArray *halfFloatArr = nullptr;
const arrow::FloatArray *floatArr = nullptr;
const arrow::DoubleArray *doubleArr = nullptr;
const arrow::FixedSizeBinaryArray *fixedSizeBinaryArr = nullptr;
const arrow::StringArray *stringArr = nullptr;
const arrow::LargeStringArray *largeStringArr = nullptr;
const arrow::BinaryArray *binArr = nullptr;
Expand Down
Loading