30#include <unordered_map>
49 static constexpr int32_t kInitialSpecId = 0;
52 static constexpr int32_t kLegacyPartitionDataIdStart = 1000;
53 static constexpr int32_t kInvalidPartitionFieldId = -1;
62 std::span<const PartitionField>
fields()
const;
83 int32_t last_assigned_field_id()
const {
return last_assigned_field_id_; }
86 return lhs.Equals(rhs);
117 const Schema& schema, int32_t spec_id, std::vector<PartitionField> fields,
118 bool allow_missing_fields,
119 std::optional<int32_t> last_assigned_field_id = std::nullopt);
129 int32_t spec_id, std::vector<PartitionField> fields,
130 std::optional<int32_t> last_assigned_field_id = std::nullopt);
132 static bool HasSequentialFieldIds(
const PartitionSpec& spec);
141 PartitionSpec(int32_t spec_id, std::vector<PartitionField> fields,
142 std::optional<int32_t> last_assigned_field_id = std::nullopt);
148 static Status ValidateRedundantPartitions(
const PartitionSpec& spec);
150 using SourceIdToFieldsMap = std::unordered_map<int32_t, std::vector<PartitionFieldRef>>;
153 const int32_t spec_id_;
154 std::vector<PartitionField> fields_;
155 int32_t last_assigned_field_id_;
A partition spec for a Table.
Definition partition_spec.h:47
Result< std::unique_ptr< StructType > > RawPartitionType(const Schema &schema) const
Get the partition type as physically written in manifest files.
std::reference_wrapper< const PartitionField > PartitionFieldRef
Get the partition fields by source ID.
Definition partition_spec.h:104
bool CompatibleWith(const PartitionSpec &other) const
Returns true if this spec is equivalent to the other, with partition field ids ignored....
Result< std::unique_ptr< StructType > > PartitionType(const Schema &schema) const
Get the partition type binding to the input schema.
static const std::shared_ptr< PartitionSpec > & Unpartitioned()
Get an unsorted partition spec singleton.
Result< std::string > PartitionPath(const PartitionValues &data) const
Get the partition path for the given partition data.
bool IsUnpartitioned() const
Return whether this spec has no non-void partition fields.
std::span< const PartitionField > fields() const
Get a list view of the partition fields.
std::string ToString() const override
Get a user-readable string representation.
int32_t spec_id() const
Get the spec ID.
static Result< std::unique_ptr< PartitionSpec > > Make(int32_t spec_id, std::vector< PartitionField > fields, std::optional< int32_t > last_assigned_field_id=std::nullopt)
Create a PartitionSpec without binding to a schema.
static Result< std::unique_ptr< PartitionSpec > > Make(const Schema &schema, int32_t spec_id, std::vector< PartitionField > fields, bool allow_missing_fields, std::optional< int32_t > last_assigned_field_id=std::nullopt)
Create a PartitionSpec binding to a schema.
Status Validate(const Schema &schema, bool allow_missing_fields) const
Validates the partition spec against a schema.
StructLike wrapper for a vector of literals that represent partition values.
Definition partition_values.h:36
A schema for a Table.
Definition schema.h:51
Define symbol visibility macros for core Iceberg APIs.
Core Apache Iceberg C++ APIs.
Definition arrow_io_util.h:33
std::expected< T, E > Result
Result alias.
Definition result.h:88
Define Result, Status, and error helpers.