@@ -73,6 +73,22 @@ ::avro::CustomAttributes GetAttributesWithFieldId(int32_t field_id) {
7373
7474} // namespace
7575
76+ std::string ToString (const ::avro::NodePtr& node) {
77+ std::stringstream ss;
78+ ss << *node;
79+ return ss.str ();
80+ }
81+
82+ std::string ToString (const ::avro::LogicalType& logical_type) {
83+ std::stringstream ss;
84+ logical_type.printJson (ss);
85+ return ss.str ();
86+ }
87+
88+ std::string ToString (const ::avro::LogicalType::Type& logical_type) {
89+ return ToString (::avro::LogicalType (logical_type));
90+ }
91+
7692Status ToAvroNodeVisitor::Visit (const BooleanType& type, ::avro::NodePtr* node) {
7793 *node = std::make_shared<::avro::NodePrimitive>(::avro::AVRO_BOOL);
7894 return {};
@@ -383,33 +399,11 @@ Status HasIdVisitor::Visit(const ::avro::Schema& schema) { return Visit(schema.r
383399
384400namespace {
385401
386- std::string ToString (const ::avro::NodePtr& node) {
387- std::stringstream ss;
388- ss << *node;
389- return ss.str ();
390- }
391-
392- std::string ToString (const ::avro::LogicalType& logical_type) {
393- std::stringstream ss;
394- logical_type.printJson (ss);
395- return ss.str ();
396- }
397-
398- std::string ToString (const ::avro::LogicalType::Type& logical_type) {
399- return ToString (::avro::LogicalType (logical_type));
400- }
401-
402402bool HasLogicalType (const ::avro::NodePtr& node,
403403 ::avro::LogicalType::Type expected_type) {
404404 return node->logicalType ().type () == expected_type;
405405}
406406
407- bool HasMapLogicalType (const ::avro::NodePtr& node) {
408- return node->logicalType ().type () == ::avro::LogicalType::CUSTOM &&
409- node->logicalType ().customLogicalType () != nullptr &&
410- node->logicalType ().customLogicalType ()->name () == " map" ;
411- }
412-
413407std::optional<std::string> GetAdjustToUtc (const ::avro::NodePtr& node) {
414408 if (node->customAttributes () == 0 ) {
415409 return std::nullopt ;
@@ -501,7 +495,7 @@ Status ValidateAvroSchemaEvolution(const Type& expected_type,
501495 case TypeId::kTimestamp :
502496 if (avro_node->type () == ::avro::AVRO_LONG &&
503497 HasLogicalType (avro_node, ::avro::LogicalType::TIMESTAMP_MICROS) &&
504- GetAdjustToUtc (avro_node).value_or (" false" ) == " true " ) {
498+ GetAdjustToUtc (avro_node).value_or (" false" ) == " false " ) {
505499 return {};
506500 }
507501 break ;
@@ -676,6 +670,10 @@ Result<FieldProjection> ProjectList(const ListType& list_type,
676670 ValidateAvroSchemaEvolution (*expected_element_field.type (), element_node));
677671 }
678672
673+ // Set the element projection metadata but preserve its children
674+ element_projection.kind = FieldProjection::Kind::kProjected ;
675+ element_projection.from = FieldProjection::SourceFieldIndex{0 };
676+
679677 FieldProjection result;
680678 result.children .emplace_back (std::move (element_projection));
681679 return result;
@@ -771,6 +769,12 @@ Result<FieldProjection> ProjectNested(const Type& expected_type,
771769
772770} // namespace
773771
772+ bool HasMapLogicalType (const ::avro::NodePtr& node) {
773+ return node->logicalType ().type () == ::avro::LogicalType::CUSTOM &&
774+ node->logicalType ().customLogicalType () != nullptr &&
775+ node->logicalType ().customLogicalType ()->name () == " map" ;
776+ }
777+
774778Result<SchemaProjection> Project (const Schema& expected_schema,
775779 const ::avro::NodePtr& avro_node, bool prune_source) {
776780 ICEBERG_ASSIGN_OR_RAISE (
0 commit comments