Skip to content

Commit 7a06fd5

Browse files
authored
Merge branch 'main' into codex/build-lumina-from-release-package
2 parents 8078ca0 + c0c627b commit 7a06fd5

19 files changed

Lines changed: 1373 additions & 47 deletions

include/paimon/file_store_commit.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,30 @@ class PAIMON_EXPORT FileStoreCommit {
135135
virtual Status DropPartition(const std::vector<std::map<std::string, std::string>>& partitions,
136136
int64_t commit_identifier) = 0;
137137

138+
/// Truncate the whole table by overwriting all partitions with empty data. The generated
139+
/// snapshot has commit kind OVERWRITE.
140+
///
141+
/// @param commit_identifier An identifier for the commit operation.
142+
/// @return Status indicating the success or failure of the truncate operation.
143+
virtual Status TruncateTable(int64_t commit_identifier) = 0;
144+
145+
/// Abort an unsuccessful commit. The data and index files described by the given commit
146+
/// messages will be deleted on a best-effort basis (delete failures are ignored).
147+
///
148+
/// @param commit_messages A vector of commit messages whose files should be cleaned up.
149+
/// @return Status indicating the success or failure of the abort operation.
150+
virtual Status Abort(const std::vector<std::shared_ptr<CommitMessage>>& commit_messages) = 0;
151+
152+
/// Roll back to the target snapshot and materialize it as the latest snapshot.
153+
///
154+
/// Reads the surviving files of both the current latest snapshot and the target
155+
/// snapshot, then commits an OVERWRITE snapshot whose visible state equals the target.
156+
///
157+
/// @param target_snapshot_id The snapshot id to roll back to.
158+
/// @return Result<bool>; true if the atomic commit succeeded. Returns an error status if
159+
/// there is no latest snapshot or the target snapshot does not exist.
160+
virtual Result<bool> RollbackToAsLatest(int64_t target_snapshot_id) = 0;
161+
138162
/// Configure row-id conflict checking from a specific snapshot id.
139163
///
140164
/// If set to a snapshot id, commit conflict detection will additionally validate row-id

src/paimon/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,7 @@ if(PAIMON_BUILD_TESTS)
720720
core/operation/commit/overwrite_changes_provider_test.cpp
721721
core/operation/commit/row_id_column_conflict_checker_test.cpp
722722
core/operation/commit/row_tracking_commit_utils_test.cpp
723+
core/operation/commit/sequence_snapshot_properties_test.cpp
723724
core/operation/commit/retry_waiter_test.cpp
724725
core/operation/key_value_file_store_write_test.cpp
725726
core/operation/internal_read_context_test.cpp
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2026-present Alibaba Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#pragma once
18+
19+
#include <string>
20+
21+
namespace paimon {
22+
23+
/// Utils for vector-store files.
24+
///
25+
/// A vector-store file is identified by the `.vector.` marker in its name.
26+
class VectorStoreUtils {
27+
public:
28+
VectorStoreUtils() = delete;
29+
~VectorStoreUtils() = delete;
30+
31+
/// Returns true if `file_name` is a vector-store file (contains the `.vector.` marker).
32+
static bool IsVectorStoreFile(const std::string& file_name) {
33+
return file_name.find(".vector.") != std::string::npos;
34+
}
35+
};
36+
37+
} // namespace paimon

src/paimon/core/core_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ struct CoreOptions::Impl {
686686
Options::SEQUENCE_FIELD, Options::FIELDS_SEPARATOR, &sequence_field));
687687
// Parse sequence.field.sort-order - order of sequence field, default "ascending"
688688
PAIMON_RETURN_NOT_OK(parser.ParseSortOrder(&sequence_field_sort_order));
689-
// Parse write-sequence-number-init-mode - sequence init mode for write path
689+
// Parse write.sequence-number-init-mode - sequence init mode for write path
690690
std::string write_sequence_init_mode_str = "scan";
691691
PAIMON_RETURN_NOT_OK(
692692
parser.Parse(Options::WRITE_SEQUENCE_NUMBER_INIT_MODE, &write_sequence_init_mode_str));

src/paimon/core/io/append_data_file_writer_factory.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ AppendDataFileWriterFactory::AppendDataFileWriterFactory(
4040
file_source_(file_source),
4141
path_factory_(path_factory) {}
4242

43+
std::shared_ptr<LongCounter> AppendDataFileWriterFactory::ResolveSeqNumCounter() const {
44+
return options_.DataEvolutionEnabled() ? std::make_shared<LongCounter>(0) : seq_num_counter_;
45+
}
46+
4347
Result<std::unique_ptr<SingleFileWriter<::ArrowArray*, std::shared_ptr<DataFileMeta>>>>
4448
AppendDataFileWriterFactory::CreateWriter() const {
45-
std::shared_ptr<LongCounter> seq_num_counter =
46-
options_.DataEvolutionEnabled() ? std::make_shared<LongCounter>(0) : seq_num_counter_;
49+
std::shared_ptr<LongCounter> seq_num_counter = ResolveSeqNumCounter();
4750
PAIMON_ASSIGN_OR_RAISE(WriterResources resources,
4851
CreateWriterResources(*options_.GetFileFormat(), write_schema_,
4952
/*create_stats_extractor=*/true));

src/paimon/core/io/append_data_file_writer_factory.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ class AppendDataFileWriterFactory
5757
CreateWriter() const override;
5858

5959
protected:
60+
// Resolves the sequence-number counter for a newly created writer. When data evolution is
61+
// enabled each file gets a fresh counter starting at 0; otherwise the factory's shared counter
62+
// is reused.
63+
std::shared_ptr<LongCounter> ResolveSeqNumCounter() const;
64+
6065
std::shared_ptr<arrow::Schema> write_schema_;
6166
std::optional<std::vector<std::string>> write_cols_;
6267
std::shared_ptr<LongCounter> seq_num_counter_;

src/paimon/core/io/shredding_append_data_file_writer_factory.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ ShreddingAppendDataFileWriterFactory::CreateWriter() const {
4747
if (!shredding_context_) {
4848
return Status::Invalid("Shared-shredding append writer requires a shredding context.");
4949
}
50-
std::shared_ptr<LongCounter> seq_num_counter =
51-
options_.DataEvolutionEnabled() ? std::make_shared<LongCounter>(0) : seq_num_counter_;
50+
std::shared_ptr<LongCounter> seq_num_counter = ResolveSeqNumCounter();
5251
PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<MapSharedShreddingBatchConverter> converter,
5352
MapSharedShreddingBatchConverter::Create(
5453
write_schema_, shredding_context_, options_, pool_));

src/paimon/core/operation/commit/commit_changes_provider_test.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ TEST(CommitChangesProviderTest, TestProvideReturnsGivenEntries) {
9999
ASSERT_EQ(delta_files.size(), provided_delta.size());
100100
ASSERT_EQ(changelog_files.size(), provided_changelog.size());
101101
ASSERT_EQ(index_entries.size(), provided_index.size());
102-
EXPECT_EQ("delta-1", provided_delta[0].FileName());
103-
EXPECT_EQ("changelog-1", provided_changelog[0].FileName());
104-
EXPECT_EQ("index-1", provided_index[0].index_file->FileName());
102+
ASSERT_EQ("delta-1", provided_delta[0].FileName());
103+
ASSERT_EQ("changelog-1", provided_changelog[0].FileName());
104+
ASSERT_EQ("index-1", provided_index[0].index_file->FileName());
105105
}
106106

107107
TEST(CommitChangesProviderTest, TestProvideUsesCopiedInputs) {
@@ -123,7 +123,7 @@ TEST(CommitChangesProviderTest, TestProvideUsesCopiedInputs) {
123123
ASSERT_EQ(1u, provided->delta_files.size());
124124
ASSERT_EQ(0u, provided->changelog_files.size());
125125
ASSERT_EQ(0u, provided->index_entries.size());
126-
EXPECT_EQ("delta-1", provided->delta_files[0].FileName());
126+
ASSERT_EQ("delta-1", provided->delta_files[0].FileName());
127127
}
128128

129129
} // namespace paimon::test

src/paimon/core/operation/commit/commit_scanner.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Snapshot;
5050
class SnapshotManager;
5151
class TableSchema;
5252

53-
// Manifest entries scanner for commit operations.
53+
/// Manifest entries scanner for commit operations.
5454
class CommitScanner {
5555
public:
5656
using ScanSupplier =

src/paimon/core/operation/commit/commit_scanner_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ TEST_F(CommitScannerTest, TestReadAllEntriesFromChangedPartitionsEmptyFastExit)
112112
ASSERT_OK_AND_ASSIGN(std::vector<ManifestEntry> entries,
113113
scanner.ReadAllEntriesFromChangedPartitions(MakeSnapshot(),
114114
/*changed_partitions=*/{}));
115-
EXPECT_TRUE(entries.empty());
116-
EXPECT_FALSE(supplier_called);
115+
ASSERT_TRUE(entries.empty());
116+
ASSERT_FALSE(supplier_called);
117117
}
118118

119119
TEST_F(CommitScannerTest, TestReadAllEntriesFromPartitionsRequiresSupplier) {
@@ -144,7 +144,7 @@ TEST_F(CommitScannerTest, TestReadAllEntriesFromChangedPartitionsBuildsScanFilte
144144
ASSERT_TRUE(supplier_called);
145145
ASSERT_EQ(1u, captured_partition_filters.size());
146146
ASSERT_EQ(1u, captured_partition_filters[0].size());
147-
EXPECT_EQ("42", captured_partition_filters[0]["pt"]);
147+
ASSERT_EQ("42", captured_partition_filters[0]["pt"]);
148148
}
149149

150150
} // namespace paimon::test

0 commit comments

Comments
 (0)