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
30#include "iceberg/result.h"
31#include "iceberg/type_fwd.h"
34
35namespace iceberg {
36
54class ICEBERG_EXPORT OverwriteFiles : public MergingSnapshotUpdate {
55 public:
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
113
119 OverwriteFiles& ConflictDetectionFilter(std::shared_ptr<Expression> expr);
120
140
161
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
Abstract base class for merge-based snapshot write operations.
Definition merging_snapshot_update.h:63
API for overwriting files in a table.
Definition overwrite_files.h:54
OverwriteFiles & CaseSensitive(bool case_sensitive)
Enable or disable case-sensitive expression binding for validations that accept expressions.
Status Validate(const TableMetadata &current_metadata, const std::shared_ptr< Snapshot > &snapshot) override
Validate the current metadata.
std::string operation() override
A string that describes the action that produced the new snapshot.
OverwriteFiles & ValidateNoConflictingData()
Enable validation that data added concurrently does not conflict with this commit's operation.
OverwriteFiles & AddFile(const std::shared_ptr< DataFile > &file)
Add a DataFile to the table.
static Result< std::shared_ptr< OverwriteFiles > > Make(std::string table_name, std::shared_ptr< TransactionContext > ctx)
Create a new OverwriteFiles instance.
OverwriteFiles & DeleteFiles(const DataFileSet &data_files_to_delete, const DeleteFileSet &delete_files_to_delete)
Delete a set of data files from the table with their respective delete files.
OverwriteFiles & OverwriteByRowFilter(std::shared_ptr< Expression > expr)
Delete files that match an expression on data rows from the table.
OverwriteFiles & ConflictDetectionFilter(std::shared_ptr< Expression > expr)
Set a conflict detection filter used to validate concurrently added data and delete files.
OverwriteFiles & ValidateFromSnapshot(int64_t snapshot_id)
Set the snapshot ID used in any reads for this operation.
OverwriteFiles & ValidateNoConflictingDeletes()
Enable validation that deletes that happened concurrently do not conflict with this commit's operatio...
OverwriteFiles & DeleteFile(const std::shared_ptr< DataFile > &file)
Delete a DataFile from the table.
OverwriteFiles & ValidateAddedFilesMatchOverwriteFilter()
Signal that each file added to the table must match the overwrite expression.
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