iceberg-cpp
Loading...
Searching...
No Matches
replace_partitions.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21
23
24#include <cstdint>
25#include <memory>
26#include <optional>
27#include <string>
28#include <vector>
29
31#include "iceberg/result.h"
32#include "iceberg/type_fwd.h"
35
36namespace iceberg {
37
58class ICEBERG_EXPORT ReplacePartitions : public MergingSnapshotUpdate {
59 public:
66 std::string table_name, std::shared_ptr<TransactionContext> ctx);
67
72 ReplacePartitions& AddFile(const std::shared_ptr<DataFile>& file);
73
79
94
105
116
117 std::string operation() override;
118
119 protected:
120 Status Validate(const TableMetadata& current_metadata,
121 const std::shared_ptr<Snapshot>& snapshot) override;
122
128 const TableMetadata& current_metadata,
129 const std::shared_ptr<Snapshot>& snapshot) override;
130
131 private:
132 explicit ReplacePartitions(std::string table_name,
133 std::shared_ptr<TransactionContext> ctx);
134
135 std::optional<int64_t> starting_snapshot_id_;
136 bool validate_conflicting_data_{false};
137 bool validate_conflicting_deletes_{false};
138 PartitionSet replaced_partitions_;
139};
140
141} // namespace iceberg
Abstract base class for merge-based snapshot write operations.
Definition merging_snapshot_update.h:63
API for overwriting files in a table by partition.
Definition replace_partitions.h:58
ReplacePartitions & ValidateFromSnapshot(int64_t snapshot_id)
Set the snapshot ID used in validations for this operation.
std::string operation() override
A string that describes the action that produced the new snapshot.
Result< std::vector< ManifestFile > > Apply(const TableMetadata &current_metadata, const std::shared_ptr< Snapshot > &snapshot) override
Apply changes, translating the fail-any-delete error.
ReplacePartitions & ValidateNoConflictingDeletes()
Enable validation that deletes that happened concurrently do not conflict with this operation.
ReplacePartitions & ValidateNoConflictingData()
Enable validation that data added concurrently does not conflict with this operation.
static Result< std::unique_ptr< ReplacePartitions > > Make(std::string table_name, std::shared_ptr< TransactionContext > ctx)
Create a new ReplacePartitions instance.
ReplacePartitions & AddFile(const std::shared_ptr< DataFile > &file)
Add a data file to the table.
ReplacePartitions & ValidateAppendOnly()
Validate that no partitions will be replaced and the operation is append-only.
Status Validate(const TableMetadata &current_metadata, const std::shared_ptr< Snapshot > &snapshot) override
Validate the current metadata.
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.
Represents the metadata for an Iceberg table.
Definition table_metadata.h:73