Skip to content

Commit 8b34d5a

Browse files
committed
fix fixed_type
1 parent 2f9a648 commit 8b34d5a

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/iceberg/avro/avro_data_util.cc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <arrow/array/builder_decimal.h>
2424
#include <arrow/array/builder_nested.h>
2525
#include <arrow/array/builder_primitive.h>
26+
#include <arrow/extension_type.h>
2627
#include <arrow/json/from_string.h>
2728
#include <arrow/type.h>
2829
#include <arrow/util/decimal.h>
@@ -536,9 +537,7 @@ Status ExtractDatumFromArray(const ::arrow::Array& array, int64_t index,
536537
internal::checked_cast<const ::arrow::FixedSizeBinaryArray&>(array);
537538
std::string_view value = fixed_array.GetView(index);
538539
auto& fixed_datum = datum->value<::avro::GenericFixed>();
539-
fixed_datum.value().assign(
540-
reinterpret_cast<const char*>(value.data()),
541-
reinterpret_cast<const char*>(value.data()) + value.size());
540+
fixed_datum.value().assign(value.begin(), value.end());
542541
return {};
543542
}
544543

@@ -573,7 +572,21 @@ Status ExtractDatumFromArray(const ::arrow::Array& array, int64_t index,
573572
return {};
574573
}
575574

576-
// TODO(gangwu): support uuid type.
575+
case ::arrow::Type::EXTENSION: {
576+
if (array.type()->name() == "arrow.uuid") {
577+
const auto& extension_array =
578+
internal::checked_cast<const ::arrow::ExtensionArray&>(array);
579+
const auto& fixed_array =
580+
internal::checked_cast<const ::arrow::FixedSizeBinaryArray&>(
581+
*extension_array.storage());
582+
std::string_view value = fixed_array.GetView(index);
583+
auto& fixed_datum = datum->value<::avro::GenericFixed>();
584+
fixed_datum.value().assign(value.begin(), value.end());
585+
return {};
586+
}
587+
588+
return NotSupported("Unsupported Arrow extension type: {}", array.type()->name());
589+
}
577590

578591
case ::arrow::Type::STRUCT: {
579592
const auto& struct_array =

0 commit comments

Comments
 (0)