Skip to content

Commit 4872162

Browse files
committed
fix windows build
1 parent b949824 commit 4872162

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/iceberg/avro/avro_schema_util.cc

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -556,23 +556,25 @@ Status ValidateAvroSchemaEvolution(const Type& expected_type,
556556
}
557557

558558
// XXX: Result<::avro::NodePtr> leads to unresolved external symbol error on Windows.
559-
Result<std::shared_ptr<::avro::Node>> UnwrapUnion(const ::avro::NodePtr& node) {
559+
Status UnwrapUnion(const ::avro::NodePtr& node, ::avro::NodePtr* result) {
560560
if (node->type() != ::avro::AVRO_UNION) {
561-
return node;
561+
*result = node;
562+
return {};
562563
}
563564
if (node->leaves() != 2) {
564565
return InvalidSchema("Union type must have exactly two branches");
565566
}
566567
auto branch_0 = node->leafAt(0);
567568
auto branch_1 = node->leafAt(1);
568569
if (branch_0->type() == ::avro::AVRO_NULL) {
569-
return branch_1;
570-
}
571-
if (branch_1->type() == ::avro::AVRO_NULL) {
572-
return branch_0;
570+
*result = branch_1;
571+
} else if (branch_1->type() == ::avro::AVRO_NULL) {
572+
*result = branch_0;
573+
} else {
574+
return InvalidSchema("Union type must have exactly one null branch, got {}",
575+
ToString(node));
573576
}
574-
return InvalidSchema("Union type must have exactly one null branch, got {}",
575-
ToString(node));
577+
return {};
576578
}
577579

578580
// Forward declaration
@@ -615,7 +617,8 @@ Result<FieldProjection> ProjectStruct(const StructType& struct_type,
615617
FieldProjection child_projection;
616618

617619
if (auto iter = node_info_map.find(field_id); iter != node_info_map.cend()) {
618-
ICEBERG_ASSIGN_OR_RAISE(auto field_node, UnwrapUnion(iter->second.field_node));
620+
::avro::NodePtr field_node;
621+
ICEBERG_RETURN_UNEXPECTED(UnwrapUnion(iter->second.field_node, &field_node));
619622
if (expected_field.type()->is_nested()) {
620623
ICEBERG_ASSIGN_OR_RAISE(
621624
child_projection,
@@ -662,7 +665,8 @@ Result<FieldProjection> ProjectList(const ListType& list_type,
662665
}
663666

664667
FieldProjection element_projection;
665-
ICEBERG_ASSIGN_OR_RAISE(auto element_node, UnwrapUnion(avro_node->leafAt(0)));
668+
::avro::NodePtr element_node;
669+
ICEBERG_RETURN_UNEXPECTED(UnwrapUnion(avro_node->leafAt(0), &element_node));
666670
if (expected_element_field.type()->is_nested()) {
667671
ICEBERG_ASSIGN_OR_RAISE(
668672
element_projection,
@@ -725,7 +729,8 @@ Result<FieldProjection> ProjectMap(const MapType& map_type,
725729

726730
for (size_t i = 0; i < map_node->leaves(); ++i) {
727731
FieldProjection sub_projection;
728-
ICEBERG_ASSIGN_OR_RAISE(auto sub_node, UnwrapUnion(map_node->leafAt(i)));
732+
::avro::NodePtr sub_node;
733+
ICEBERG_RETURN_UNEXPECTED(UnwrapUnion(map_node->leafAt(i), &sub_node));
729734
const auto& expected_sub_field = map_type.fields()[i];
730735
if (expected_sub_field.type()->is_nested()) {
731736
ICEBERG_ASSIGN_OR_RAISE(sub_projection, ProjectNested(*expected_sub_field.type(),

0 commit comments

Comments
 (0)