Skip to content

Commit d5bb0bf

Browse files
format code
1 parent 6c74bb3 commit d5bb0bf

3 files changed

Lines changed: 20 additions & 19 deletions

File tree

src/iceberg/avro/avro_reader.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class AvroReader::Impl {
111111
MakeAvroNodeWithFieldIds(file_schema.root(), *options.name_mapping));
112112

113113
// Update the file schema to use the new schema with field IDs
114-
file_schema = ::avro::ValidSchema(new_root_node);;
114+
file_schema = ::avro::ValidSchema(new_root_node);
115115
} else {
116116
return InvalidSchema(
117117
"Avro file schema has no field IDs and no name mapping provided");

src/iceberg/avro/avro_schema_util.cc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,8 @@ Result<::avro::NodePtr> CreateMapNodeWithFieldIds(const ::avro::NodePtr& origina
912912

913913
auto new_map_node = std::make_shared<::avro::NodeMap>();
914914

915-
// For map types, we need to extract key and value field mappings from the nested mapping
915+
// For map types, we need to extract key and value field mappings from the nested
916+
// mapping
916917
if (!field.nested_mapping) {
917918
return InvalidSchema("Map type requires nested mapping for key and value fields");
918919
}
@@ -926,7 +927,8 @@ Result<::avro::NodePtr> CreateMapNodeWithFieldIds(const ::avro::NodePtr& origina
926927
}
927928

928929
std::optional<MappedFieldConstRef> key_field_ref = field.nested_mapping->Field(*key_id);
929-
std::optional<MappedFieldConstRef> value_field_ref = field.nested_mapping->Field(*value_id);
930+
std::optional<MappedFieldConstRef> value_field_ref =
931+
field.nested_mapping->Field(*value_id);
930932

931933
if (!key_field_ref || !value_field_ref) {
932934
return InvalidSchema("Map type requires both key and value field mappings");
@@ -950,16 +952,16 @@ Result<::avro::NodePtr> CreateMapNodeWithFieldIds(const ::avro::NodePtr& origina
950952
value_field.nested_mapping = value_mapped_field.nested_mapping;
951953

952954
// Add key and value nodes
953-
ICEBERG_ASSIGN_OR_RAISE(
954-
auto new_key_node, MakeAvroNodeWithFieldIds(original_node->leafAt(0), key_field));
955+
ICEBERG_ASSIGN_OR_RAISE(auto new_key_node,
956+
MakeAvroNodeWithFieldIds(original_node->leafAt(0), key_field));
955957
ICEBERG_ASSIGN_OR_RAISE(
956958
auto new_value_node,
957959
MakeAvroNodeWithFieldIds(original_node->leafAt(1), value_field));
958960
new_map_node->addLeaf(new_key_node);
959961
new_map_node->addLeaf(new_value_node);
960962

961-
// Preserve existing custom attributes from the original node and add field ID attributes
962-
// Copy existing attributes from the original node (if any)
963+
// Preserve existing custom attributes from the original node and add field ID
964+
// attributes Copy existing attributes from the original node (if any)
963965
if (original_node->customAttributes() > 0) {
964966
const auto& original_attrs = original_node->customAttributesAt(0);
965967
const auto& existing_attrs = original_attrs.attributes();
@@ -971,7 +973,6 @@ Result<::avro::NodePtr> CreateMapNodeWithFieldIds(const ::avro::NodePtr& origina
971973
}
972974
}
973975

974-
// Add field ID attributes for key and value as separate custom attributes
975976
::avro::CustomAttributes key_attributes;
976977
key_attributes.addAttribute(std::string(kFieldIdProp),
977978
std::to_string(*key_mapped_field.field_id), false);
@@ -999,16 +1000,14 @@ Result<::avro::NodePtr> CreateUnionNodeWithFieldIds(const ::avro::NodePtr& origi
9991000

10001001
if (branch_0_is_null && !branch_1_is_null) {
10011002
// branch_0 is null, branch_1 is not null
1002-
ICEBERG_ASSIGN_OR_RAISE(auto new_branch_1,
1003-
MakeAvroNodeWithFieldIds(branch_1, field));
1003+
ICEBERG_ASSIGN_OR_RAISE(auto new_branch_1, MakeAvroNodeWithFieldIds(branch_1, field));
10041004
auto new_union_node = std::make_shared<::avro::NodeUnion>();
10051005
new_union_node->addLeaf(branch_0); // null branch
10061006
new_union_node->addLeaf(new_branch_1);
10071007
return new_union_node;
10081008
} else if (!branch_0_is_null && branch_1_is_null) {
10091009
// branch_0 is not null, branch_1 is null
1010-
ICEBERG_ASSIGN_OR_RAISE(auto new_branch_0,
1011-
MakeAvroNodeWithFieldIds(branch_0, field));
1010+
ICEBERG_ASSIGN_OR_RAISE(auto new_branch_0, MakeAvroNodeWithFieldIds(branch_0, field));
10121011
auto new_union_node = std::make_shared<::avro::NodeUnion>();
10131012
new_union_node->addLeaf(new_branch_0);
10141013
new_union_node->addLeaf(branch_1); // null branch
@@ -1025,7 +1024,7 @@ Result<::avro::NodePtr> CreateUnionNodeWithFieldIds(const ::avro::NodePtr& origi
10251024
} // namespace
10261025

10271026
Result<::avro::NodePtr> MakeAvroNodeWithFieldIds(const ::avro::NodePtr& original_node,
1028-
const MappedField& mapped_field) {
1027+
const MappedField& mapped_field) {
10291028
switch (original_node->type()) {
10301029
case ::avro::AVRO_RECORD:
10311030
return CreateRecordNodeWithFieldIds(original_node, mapped_field);
@@ -1054,7 +1053,7 @@ Result<::avro::NodePtr> MakeAvroNodeWithFieldIds(const ::avro::NodePtr& original
10541053
}
10551054

10561055
Result<::avro::NodePtr> MakeAvroNodeWithFieldIds(const ::avro::NodePtr& original_node,
1057-
const NameMapping& mapping) {
1056+
const NameMapping& mapping) {
10581057
MappedField mapped_field;
10591058
mapped_field.nested_mapping = std::make_shared<MappedFields>(mapping.AsMappedFields());
10601059
return MakeAvroNodeWithFieldIds(original_node, mapped_field);

test/avro_schema_test.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,8 @@ class NameMappingAvroSchemaTest : public ::testing::Test {
11321132
return NameMapping::Make(std::move(fields));
11331133
}
11341134

1135-
// Helper function to create a name mapping for complex map types (array<struct<key,value>>)
1135+
// Helper function to create a name mapping for complex map types
1136+
// (array<struct<key,value>>)
11361137
std::unique_ptr<NameMapping> CreateComplexMapNameMapping() {
11371138
std::vector<MappedField> fields;
11381139
fields.emplace_back(MappedField{.names = {"id"}, .field_id = 1});
@@ -1145,12 +1146,13 @@ class NameMappingAvroSchemaTest : public ::testing::Test {
11451146

11461147
// Nested mapping for array
11471148
std::vector<MappedField> array_fields;
1148-
array_fields.emplace_back(MappedField{.names = {"element"}, .field_id = 50, .nested_mapping = std::move(element_mapping)});
1149+
array_fields.emplace_back(MappedField{.names = {"element"},
1150+
.field_id = 50,
1151+
.nested_mapping = std::move(element_mapping)});
11491152
auto array_mapping = MappedFields::Make(std::move(array_fields));
11501153

1151-
fields.emplace_back(MappedField{.names = {"entries"},
1152-
.field_id = 2,
1153-
.nested_mapping = std::move(array_mapping)});
1154+
fields.emplace_back(MappedField{
1155+
.names = {"entries"}, .field_id = 2, .nested_mapping = std::move(array_mapping)});
11541156

11551157
return NameMapping::Make(std::move(fields));
11561158
}

0 commit comments

Comments
 (0)