YinZheng-Sun commented on code in PR #1068:
URL: https://github.com/apache/iceberg-cpp/pull/1068#discussion_r4695593591


##########
src/iceberg/test/file_scan_task_reader_test.cc:
##########
@@ -421,6 +424,165 @@ class FileScanTaskReaderTest : public TempFileTestBase {
   std::shared_ptr<Schema> projected_schema_;
 };
 
+TEST_F(FileScanTaskReaderTest, IdentityPartitionConstantsSurviveJsonAndSplit) {
+  auto physical = std::make_shared<Schema>(
+      std::vector<SchemaField>{SchemaField::MakeRequired(1, "id", int32())});
+  ICEBERG_UNWRAP_OR_FAIL(auto file, MakeDataFile(physical, "[[1], [2], [3]]"));
+  ICEBERG_UNWRAP_OR_FAIL(
+      auto spec, PartitionSpec::Make(7, {{2, 1000, "name", 
Transform::Identity()}}));
+  file->partition_spec_id = 7;
+  file->partition = PartitionValues({Literal::String("CN")});
+  FileScanTask task(file, {}, nullptr, std::move(spec));
+  ICEBERG_UNWRAP_OR_FAIL(
+      auto json, ToJson(task, {{7, 
std::const_pointer_cast<PartitionSpec>(task.spec())}},
+                        *table_schema_));
+  ICEBERG_UNWRAP_OR_FAIL(auto parsed, FileScanTaskFromJson(json));
+  ASSERT_NE(parsed->spec(), nullptr);
+  EXPECT_EQ(parsed->spec()->spec_id(), 7);
+  ICEBERG_UNWRAP_OR_FAIL(
+      auto split, FileScanTask::MakeSplit(parsed->data_file(), 0, 
parsed->length(), {},
+                                          nullptr, parsed->spec()));

Review Comment:
   You're right,thx!  Use `[0, length - 1) and added 
`ASSERT_TRUE(split->is_split())` before checking that the spec is preserved.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to