@@ -729,39 +729,41 @@ TEST_P(UpdatePartitionSpecTest, TestRemoveAndAddMultiTimes) {
729729 update3->AddField (Expressions::Day (" ts" ), " ts_date" );
730730 auto add_second_time_spec = ApplyUpdateAndGetSpec (update3);
731731
732- // Remove second time
733- auto table3 = CreateTableWithSpec (add_second_time_spec, " test_table3" );
734- auto update4 = CreateUpdateFromTable (table3);
735- update4->RemoveField (Expressions::Day (" ts" ));
736- auto remove_second_time_spec = ApplyUpdateAndGetSpec (update4);
737-
738732 // Add third time with month
739- auto table4 = CreateTableWithSpec (remove_second_time_spec , " test_table4" );
733+ auto table4 = CreateTableWithSpec (add_second_time_spec , " test_table4" );
740734 auto update5 = CreateUpdateFromTable (table4);
741- update5->AddField (Expressions::Month (" ts" ));
735+ update5->AddField (Expressions::Month (" ts" ), " ts_month " );
742736 auto add_third_time_spec = ApplyUpdateAndGetSpec (update5);
743737
744738 // Rename ts_month to ts_date
745739 auto table5 = CreateTableWithSpec (add_third_time_spec, " test_table5" );
746740 auto update6 = CreateUpdateFromTable (table5);
747- update6->RenameField (" ts_month" , " ts_date " );
741+ update6->RenameField (" ts_month" , " __ts_date " );
748742 auto updated_spec = ApplyUpdateAndGetSpec (update6);
749743
750744 if (format_version_ == 1 ) {
745+ // Remove second time
746+ auto table3 = CreateTableWithSpec (add_second_time_spec, " test_table3" );
747+ auto update4 = CreateUpdateFromTable (table3);
748+ update4->RemoveField (Expressions::Day (" ts" ));
749+ ExpectError (update4, ErrorKind::kValidationFailed ,
750+ " Cannot add redundant partition: ts_date" );
751+
751752 ASSERT_EQ (updated_spec->fields ().size (), 3 );
752753 // In V1, we expect void transforms for deleted fields
753754 EXPECT_TRUE (updated_spec->fields ()[0 ].name ().find (" ts_date" ) == 0 );
754755 EXPECT_TRUE (updated_spec->fields ()[1 ].name ().find (" ts_date" ) == 0 );
755- EXPECT_EQ (updated_spec->fields ()[2 ].name (), " ts_date " );
756+ EXPECT_EQ (updated_spec->fields ()[2 ].name (), " __ts_date " );
756757 EXPECT_EQ (*updated_spec->fields ()[0 ].transform (), *Transform::Void ());
757- EXPECT_EQ (*updated_spec->fields ()[1 ].transform (), *Transform::Void ());
758+ EXPECT_EQ (*updated_spec->fields ()[1 ].transform (), *Transform::Day ());
758759 EXPECT_EQ (*updated_spec->fields ()[2 ].transform (), *Transform::Month ());
759760 } else {
760761 ICEBERG_UNWRAP_OR_FAIL (
761762 auto expected_spec,
762763 PartitionSpec::Make (PartitionSpec::kInitialSpecId ,
763764 std::vector<PartitionField>{
764- PartitionField (2 , 1000 , " ts_date" , Transform::Month ())},
765+ PartitionField (2 , 1000 , " ts_date" , Transform::Day ()),
766+ PartitionField (2 , 1001 , " __ts_date" , Transform::Month ())},
765767 1000 ));
766768 auto expected = std::shared_ptr<PartitionSpec>(expected_spec.release ());
767769 AssertPartitionSpecEquals (*expected, *updated_spec);
0 commit comments