26#include <unordered_map>
27#include <unordered_set>
30#include "iceberg/iceberg_export.h"
31#include "iceberg/result.h"
34#include "iceberg/util/string_util.h"
45 std::unordered_map<int32_t, std::reference_wrapper<const SchemaField>>&
51 std::unordered_map<int32_t, std::reference_wrapper<const SchemaField>>& id_to_field_;
59 std::unordered_map<std::string, int32_t,
StringHash, std::equal_to<>>& name_to_id,
60 std::unordered_map<int32_t, std::string>* id_to_name,
bool case_sensitive =
true,
61 std::function<std::string(std::string_view)> quoting_func = {});
62 Status Visit(
const ListType& type,
const std::string& path,
63 const std::string& short_path);
64 Status
Visit(
const MapType& type,
const std::string& path,
65 const std::string& short_path);
67 const std::string& short_path);
69 const std::string& short_path);
73 std::string BuildPath(std::string_view prefix, std::string_view field_name,
78 std::unordered_map<std::string, int32_t, StringHash, std::equal_to<>>& name_to_id_;
79 std::unordered_map<int32_t, std::string>* id_to_name_;
80 std::unordered_map<std::string, int32_t, StringHash, std::equal_to<>> short_name_to_id_;
81 std::function<std::string(std::string_view)> quoting_func_;
91 std::unordered_map<int32_t, std::vector<size_t>> Finish();
94 constexpr static int32_t kUnassignedFieldId = -1;
95 int32_t current_field_id_ = kUnassignedFieldId;
96 std::vector<size_t> current_path_;
97 std::unordered_map<int32_t, std::vector<size_t>> position_path_;
111 bool select_full_types);
113 Result<std::shared_ptr<Type>> Visit(
const std::shared_ptr<Type>& type)
const;
116 Result<std::shared_ptr<Type>>
Visit(
const std::shared_ptr<StructType>& type)
const;
117 Result<std::shared_ptr<Type>>
Visit(
const std::shared_ptr<ListType>& type)
const;
118 Result<std::shared_ptr<Type>>
Visit(
const std::shared_ptr<MapType>& type)
const;
121 const std::unordered_set<int32_t>& selected_ids_;
122 const bool select_full_types_;
130 Status Visit(
const Type& type);
133 std::unordered_set<int32_t> Finish()
const;
135 static Result<std::unordered_set<int32_t>> GetProjectedIds(
136 const Type& type,
bool include_struct_ids =
false);
139 const bool include_struct_ids_;
140 std::unordered_set<int32_t> ids_;
151ICEBERG_EXPORT std::unordered_map<int32_t, int32_t> IndexParents(
159 std::shared_ptr<Type> Visit(
const std::shared_ptr<Type>& type)
const;
162 std::shared_ptr<MapType>
Visit(
const MapType& type)
const;
165 std::function<int32_t()> next_id_;
174ICEBERG_EXPORT Result<std::shared_ptr<Schema>> AssignFreshIds(
175 int32_t schema_id,
const Schema& schema, std::function<int32_t()> next_id);
187ICEBERG_EXPORT
bool IsPromotionAllowed(
const std::shared_ptr<Type>& from_type,
188 const std::shared_ptr<Type>& to_type);
Assigns fresh IDs to all fields in the schema.
Definition type_util.h:155
Visitor for getting projected field IDs.
Definition type_util.h:126
Visitor for building a map from field ID to SchemaField reference.
Definition type_util.h:42
A data type representing a list of values.
Definition type.h:145
A data type representing a dictionary of values.
Definition type.h:177
Visitor for building maps from field name to field ID and field ID to field name.
Definition type_util.h:56
A data type that has child fields.
Definition type.h:73
Visitor for building a map from field ID to position path.
Definition type_util.h:85
A data type that does not have child fields.
Definition type.h:66
Visitor for pruning columns based on selected field IDs.
Definition type_util.h:108
A type combined with a name.
Definition schema_field.h:39
A schema for a Table.
Definition schema.h:49
A data type representing a struct with nested fields.
Definition type.h:108
Interface for a data type for a field.
Definition type.h:44
Result< R > Visit(const std::shared_ptr< Expression > &expr, V &visitor)
Traverse an expression tree with a visitor.
Definition expression_visitor.h:283
Transparent hash function that supports std::string_view as lookup key.
Definition string_util.h:137