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);
61 Status
Visit(
const MapType& type, ::avro::NodePtr* node);
66 std::stack<int32_t> field_ids_;
78 Status
Visit(const ::avro::NodePtr& node);
84 Status
Visit(const ::avro::ValidSchema& schema);
90 Status
Visit(const ::avro::Schema& node);
95 return total_fields_ == fields_with_id_ && fields_with_id_ != 0;
100 bool HasNoIds()
const {
return total_fields_ == 0; }
106 Status VisitRecord(const ::avro::NodePtr& node);
111 Status VisitArray(const ::avro::NodePtr& node);
116 Status VisitMap(const ::avro::NodePtr& node);
121 Status VisitUnion(const ::avro::NodePtr& node);
125 size_t total_fields_ = 0;
127 size_t fields_with_id_ = 0;
140Result<SchemaProjection> Project(
const Schema& expected_schema,
141 const ::avro::NodePtr& avro_node,
bool prune_source);
143std::string ToString(const ::avro::NodePtr& node);
144std::string ToString(const ::avro::LogicalType& logical_type);
145std::string ToString(const ::avro::LogicalType::Type& logical_type);
150bool HasMapLogicalType(const ::avro::NodePtr& node);
160bool ValidAvroName(std::string_view name);
166Result<::avro::NodePtr> MakeAvroNodeWithFieldIds(const ::avro::NodePtr& original_node,
190std::string SanitizeFieldName(std::string_view field_name);
A data type representing an arbitrary-length byte sequence.
Definition type.h:400
A data type representing a boolean (true or false).
Definition type.h:216
A data type representing a calendar date without reference to a timezone or time.
Definition type.h:321
A data type representing a fixed-precision decimal.
Definition type.h:293
A data type representing a 64-bit (double precision) IEEE-754 float.
Definition type.h:278
A data type representing a fixed-length bytestring.
Definition type.h:431
A data type representing a 32-bit (single precision) IEEE-754 float.
Definition type.h:262
A data type representing a 32-bit signed integer.
Definition type.h:231
A data type representing a list of values.
Definition type.h:145
A data type representing a 64-bit signed integer.
Definition type.h:246
A data type representing a dictionary of values.
Definition type.h:177
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:49
A data type representing an arbitrary-length character sequence (encoded in UTF-8).
Definition type.h:416
A data type representing a struct with nested fields.
Definition type.h:108
A data type representing a wall clock time in microseconds without reference to a timezone or date.
Definition type.h:337
A data type representing a timestamp in microseconds without reference to a timezone.
Definition type.h:363
A data type representing a timestamp as microseconds since the epoch in UTC. A time zone or offset is...
Definition type.h:382
A data type representing a UUID. While defined as a distinct type, it is effectively a fixed(16).
Definition type.h:454
A visitor that checks the presence of field IDs in an Avro schema.
Definition avro_schema_util_internal.h:70
Status Visit(const ::avro::NodePtr &node)
Visit an Avro node to check for field IDs.
Definition avro_schema_util.cc:346
bool AllHaveIds() const
Check if all fields in the visited schema have field IDs.
Definition avro_schema_util_internal.h:94
bool HasNoIds() const
Check if all fields in the visited schema have field IDs.
Definition avro_schema_util_internal.h:100
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