lxy-9602 commented on code in PR #447:
URL: https://github.com/apache/paimon-cpp/pull/447#discussion_r4376203123
##########
test/inte/realtime_write_inte_test.cpp:
##########
@@ -559,6 +560,41 @@ class RealtimeWriteInteTest : public ::testing::Test {
return FileStoreWrite::Create(std::move(context));
}
+ // A writer that means to change an option the table was created with
writes through a copy
+ // carrying it, which the context then agrees with.
+ Result<std::shared_ptr<Table>> CopiedTable(
+ const std::map<std::string, std::string>& overrides) const {
+ PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<Catalog> catalog,
Catalog::Create(dir_->Str(), {}));
+ PAIMON_ASSIGN_OR_RAISE(std::shared_ptr<Table> table,
+ catalog->GetTable(Identifier("foo", "bar")));
+ return table->Copy(overrides);
+ }
+
+ // Evolves the table schema to the current options with its fields
unchanged, the way an
+ // ALTER TABLE changing an option would: the table itself then serves the
changed option.
+ // The fields are carried over from the latest schema so their attributes
survive: rebuilt
+ // raw fields would lose the non-nullable primary keys the table schema
enforces.
+ Status EvolveSchemaWithOptions() const {
+ SchemaManager schema_manager(dir_->GetFileSystem(), table_path_);
+ PAIMON_ASSIGN_OR_RAISE(std::optional<std::shared_ptr<TableSchema>>
latest,
+ schema_manager.Latest());
+ if (!latest.has_value()) {
+ return Status::Invalid("table schema does not exist");
+ }
+ return TestHelper::WriteNextSchema(dir_->GetFileSystem(), table_path_,
+ latest.value()->Fields(),
+ latest.value()->HighestFieldId(),
options_);
+ }
+
+ Result<std::unique_ptr<FileStoreWrite>> CreateRealtimeWriter(
+ const std::shared_ptr<RealtimeContext>& realtime_context,
+ const std::shared_ptr<Table>& table) const {
+ WriteContextBuilder builder(table_path_, commit_user_);
+
builder.SetOptions(options_).WithStreamingMode(true).WithRealtimeContext(realtime_context);
+ PAIMON_ASSIGN_OR_RAISE(std::unique_ptr<WriteContext> context,
builder.Finish());
+ return table->NewWrite(std::move(context));
+ }
Review Comment:
Is this function used anywhere?
##########
test/inte/realtime_write_inte_test.cpp:
##########
@@ -2084,6 +2124,9 @@ TEST_F(RealtimeWriteInteTest,
TestRealtimeDeduplicateAcrossMultipleFileIndexStor
ASSERT_OK(embedded_writer->Close());
options_[Options::FILE_INDEX_IN_MANIFEST_THRESHOLD] = "1B";
+ // The tighter threshold is a change the table itself carries, the way an
ALTER TABLE would:
+ // the schema is evolved to it, so every later write, commit, and read
serves it.
+ ASSERT_OK(EvolveSchemaWithOptions());
Review Comment:
Why do we need real schema evolution and a new schema file here? In
practice, users might also use some session-level settings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]