24#include <avro/Node.hh>
26#include "iceberg/name_mapping.h"
27#include "iceberg/result.h"
28#include "iceberg/schema_util.h"
36namespace iceberg::avro {
45 Status Visit(
const BooleanType& type, ::avro::NodePtr* node);
46 Status
Visit(
const IntType& type, ::avro::NodePtr* node);
67 Status
Visit(
const MapType& type, ::avro::NodePtr* node);
72 std::stack<int32_t> field_ids_;
84 Status
Visit(const ::avro::NodePtr& node);
90 Status
Visit(const ::avro::ValidSchema& schema);
96 Status
Visit(const ::avro::Schema& node);
101 return total_fields_ == fields_with_id_ && fields_with_id_ != 0;
106 bool HasNoIds()
const {
return total_fields_ == 0; }
112 Status VisitRecord(const ::avro::NodePtr& node);
117 Status VisitArray(const ::avro::NodePtr& node);
122 Status VisitMap(const ::avro::NodePtr& node);
127 Status VisitUnion(const ::avro::NodePtr& node);
131 size_t total_fields_ = 0;
133 size_t fields_with_id_ = 0;
146Result<SchemaProjection> Project(
const Schema& expected_schema,
147 const ::avro::NodePtr& avro_node,
bool prune_source);
149std::string ToString(const ::avro::NodePtr& node);
150std::string ToString(const ::avro::LogicalType& logical_type);
151std::string ToString(const ::avro::LogicalType::Type& logical_type);
159bool IsAvroDateOrPlainInt(const ::avro::NodePtr& node);
164bool HasMapLogicalType(const ::avro::NodePtr& node);
174bool ValidAvroName(std::string_view name);
180Result<::avro::NodePtr> MakeAvroNodeWithFieldIds(const ::avro::NodePtr& original_node,
204std::string SanitizeFieldName(std::string_view field_name);
A data type representing an arbitrary-length byte sequence.
Definition type.h:480
A data type representing a boolean (true or false).
Definition type.h:257
A data type representing a calendar date without reference to a timezone or time.
Definition type.h:363
A data type representing a fixed-precision decimal.
Definition type.h:334
A data type representing a 64-bit (double precision) IEEE-754 float.
Definition type.h:319
A data type representing a fixed-length bytestring.
Definition type.h:511
A data type representing a 32-bit (single precision) IEEE-754 float.
Definition type.h:303
A data type representing OGC geography in WKB format.
Definition type.h:590
A data type representing OGC geometry in WKB format.
Definition type.h:565
A data type representing a 32-bit signed integer.
Definition type.h:272
A data type representing a list of values.
Definition type.h:156
A data type representing a 64-bit signed integer.
Definition type.h:287
A data type representing a dictionary of values.
Definition type.h:191
Represents a mapping from external schema names to Iceberg type IDs.
Definition name_mapping.h:96
A type combined with a name.
Definition schema_field.h:39
A schema for a Table.
Definition schema.h:51
A data type representing an arbitrary-length character sequence (encoded in UTF-8).
Definition type.h:496
A data type representing a struct with nested fields.
Definition type.h:119
A data type representing a wall clock time in microseconds without reference to a timezone or date.
Definition type.h:379
A data type representing a timestamp in nanoseconds without reference to a timezone.
Definition type.h:443
A data type representing a timestamp in microseconds without reference to a timezone.
Definition type.h:405
A data type representing a timestamp as nanoseconds since the epoch in UTC. A time zone or offset is ...
Definition type.h:462
A data type representing a timestamp as microseconds since the epoch in UTC. A time zone or offset is...
Definition type.h:424
A null-only placeholder type used when a more specific type is not known.
Definition type.h:550
A data type representing a UUID. While defined as a distinct type, it is effectively a fixed(16).
Definition type.h:535
A semi-structured type whose structure may vary across rows.
Definition type.h:233
A visitor that checks the presence of field IDs in an Avro schema.
Definition avro_schema_util_internal.h:76
Status Visit(const ::avro::NodePtr &node)
Visit an Avro node to check for field IDs.
Definition avro_schema_util.cc:387
bool AllHaveIds() const
Check if all fields in the visited schema have field IDs.
Definition avro_schema_util_internal.h:100
bool HasNoIds() const
Check if all fields in the visited schema have field IDs.
Definition avro_schema_util_internal.h:106
A visitor that converts an Iceberg type to an Avro node.
Definition avro_schema_util_internal.h:43
Result< R > Visit(const std::shared_ptr< Expression > &expr, V &visitor)
Traverse an expression tree with a visitor.
Definition expression_visitor.h:283
Definition avro_schema_util_internal.h:38