@@ -57,7 +57,8 @@ Result<UnionBranches> ValidateUnion(const ::avro::NodePtr& union_node) {
5757 return UnionBranches{.null_index = 0 , .value_index = 1 , .value_node = branch_1};
5858 }
5959 if (branch_1->type () == ::avro::AVRO_NULL && branch_0->type () != ::avro::AVRO_NULL ) {
60- return UnionBranches{.null_index = 1 , .value_index = 0 , .value_node = branch_0};
60+ return Status::Invalid (
61+ " Unexpected: In paimon, we expect the null branch to be the first branch in a union." );
6162 }
6263 return Status::Invalid (" Union must have exactly one null branch" );
6364}
@@ -92,10 +93,6 @@ Status AvroDirectEncoder::EncodeArrowToAvro(const ::avro::NodePtr& avro_node,
9293 }
9394
9495 switch (avro_node->type ()) {
95- case ::avro::AVRO_NULL :
96- encoder->encodeNull ();
97- return Status::OK ();
98-
9996 case ::avro::AVRO_BOOL : {
10097 const auto & bool_array =
10198 arrow::internal::checked_cast<const arrow::BooleanArray&>(array);
@@ -294,7 +291,7 @@ Status AvroDirectEncoder::EncodeArrowToAvro(const ::avro::NodePtr& avro_node,
294291 element_node->leaves () != 2 )) {
295292 return Status::Invalid (
296293 fmt::format (" Expected AVRO_RECORD for map key-value pair, got {}" ,
297- ::avro::toString (element_node-> type () )));
294+ AvroUtils::ToString (avro_node )));
298295 }
299296
300297 const auto & map_array =
@@ -366,9 +363,11 @@ Status AvroDirectEncoder::EncodeArrowToAvro(const ::avro::NodePtr& avro_node,
366363 return Status::OK ();
367364 }
368365
366+ case ::avro::AVRO_NULL :
369367 case ::avro::AVRO_UNION :
370368 // Already handled above
371- return Status::Invalid (" Unexpected union handling" );
369+ return Status::Invalid (fmt::format (" Unexpected Avro type handling: {}" ,
370+ ::avro::toString (avro_node->type ())));
372371 default :
373372 return Status::Invalid(
374373 fmt::format (" Unsupported Avro type: {}" , ::avro::toString(avro_node->type ())));
0 commit comments