marton-bod commented on code in PR #4602:
URL: https://github.com/apache/iceberg/pull/4602#discussion_r980127410
##########
spark/v3.2/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestAlterTablePartitionFields.java:
##########
@@ -421,6 +421,78 @@ public void testSparkTableAddDropPartitions() throws
Exception {
"spark table partition should be empty", 0,
sparkTable().partitioning().length);
}
+ @Test
+ public void testUnboundPartitionSpecFormatVersion1() throws Exception {
+ sql(
+ "CREATE TABLE IF NOT EXISTS %s (id bigint NOT NULL, ts timestamp, data
string) USING iceberg "
+ + "TBLPROPERTIES ('format-version' = 1, 'write.delete.mode' =
'merge-on-read')",
+ tableName);
+ Assert.assertEquals(
+ "spark table partition should be empty", 0,
sparkTable().partitioning().length);
+
+ sql("INSERT INTO %s VALUES (1, current_timestamp(),
'format-version-1-first-data')", tableName);
+ Assert.assertEquals(
+ "Should have 1 rows after insert", 1L, scalarSql("SELECT count(*) FROM
%s", tableName));
+
+ sql("ALTER TABLE %s ADD PARTITION FIELD truncate(data, 4)", tableName);
+ assertPartitioningEquals(sparkTable(), 1, "truncate(data, 4)");
+
+ sql(
+ "INSERT INTO %s VALUES (2, current_timestamp(),
'format-version-1-second-data')",
+ tableName);
+ Assert.assertEquals(
+ "Should have 2 rows after insert", 2L, scalarSql("SELECT count(*) FROM
%s", tableName));
+
+ sql("ALTER TABLE %s DROP PARTITION FIELD truncate(data, 4)", tableName);
+ Assert.assertEquals(
+ "spark table partition should be empty", 0,
sparkTable().partitioning().length);
+
+ sql("INSERT INTO %s VALUES (3, current_timestamp(),
'format-version-1-third-data')", tableName);
+ Assert.assertEquals(
+ "Should have 3 rows after insert", 3L, scalarSql("SELECT count(*) FROM
%s", tableName));
+
+ sql("ALTER TABLE %s DROP COLUMN data", tableName);
+
+ Assert.assertEquals(
Review Comment:
In addition to the data read test, shall we add a test to read back the
`partitions` metatable contents as well?
--
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]