iceberg-cpp
Loading...
Searching...
No Matches
overwrite_files.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
29#include "iceberg/iceberg_export.h"
30#include "iceberg/result.h"
31#include "iceberg/type_fwd.h"
34
35namespace iceberg {
36
54class ICEBERG_EXPORT OverwriteFiles : public MergingSnapshotUpdate {
55 public:
61 static Result<std::shared_ptr<OverwriteFiles>> Make(
62 std::string table_name, std::shared_ptr<TransactionContext> ctx);
63
64 ~OverwriteFiles() override;
65
70 OverwriteFiles& AddFile(const std::shared_ptr<DataFile>& file);
71
76 OverwriteFiles& DeleteFile(const std::shared_ptr<DataFile>& file);
77
85 OverwriteFiles& DeleteFiles(const DataFileSet& data_files_to_delete,
86 const DeleteFileSet& delete_files_to_delete);
87
102 OverwriteFiles& OverwriteByRowFilter(std::shared_ptr<Expression> expr);
103
112 OverwriteFiles& ValidateFromSnapshot(int64_t snapshot_id);
113
119 OverwriteFiles& ConflictDetectionFilter(std::shared_ptr<Expression> expr);
120
139 OverwriteFiles& ValidateNoConflictingData();
140
160 OverwriteFiles& ValidateNoConflictingDeletes();
161
171 OverwriteFiles& ValidateAddedFilesMatchOverwriteFilter();
172
178 OverwriteFiles& CaseSensitive(bool case_sensitive);
179
180 std::string operation() override;
181
182 protected:
183 Status Validate(const TableMetadata& current_metadata,
184 const std::shared_ptr<Snapshot>& snapshot) override;
185
186 private:
187 explicit OverwriteFiles(std::string table_name,
188 std::shared_ptr<TransactionContext> ctx);
189
191 std::shared_ptr<Expression> DataConflictDetectionFilter() const;
192
193 DataFileSet deleted_data_files_;
194 bool validate_added_files_match_overwrite_filter_ = false;
195 std::optional<int64_t> starting_snapshot_id_;
196 std::shared_ptr<Expression> conflict_detection_filter_;
197 bool validate_new_data_files_ = false;
198 bool validate_new_deletes_ = false;
199};
200
201} // namespace iceberg
A set of DataFile pointers with insertion order preserved and deduplicated by file path.
Definition data_file_set.h:44
A set of delete-file pointers deduplicated by delete-file identity.
Definition data_file_set.h:144
API for deleting data files from a table.
Definition delete_files.h:44
Abstract base class for merge-based snapshot write operations.
Definition merging_snapshot_update.h:69
API for overwriting files in a table.
Definition overwrite_files.h:54
Represents the metadata for an Iceberg table.
Definition table_metadata.h:73