szehon-ho commented on code in PR #7120:
URL: https://github.com/apache/iceberg/pull/7120#discussion_r1163431621
##########
spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionedWrites.java:
##########
@@ -157,4 +158,87 @@ public void testViewsReturnRecentResults() {
ImmutableList.of(row(1L, "a"), row(1L, "a")),
sql("SELECT * FROM tmp"));
}
+
+ @Test
+ public void testWriteWithOutputSpec() throws NoSuchTableException {
+ Table table = validationCatalog.loadTable(tableIdent);
+ // Drop all records in table to have a fresh start.
+ sql("DELETE FROM %s", tableName);
Review Comment:
Is this necessary? It looks like table is dropped after every test?
##########
spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionedWrites.java:
##########
@@ -157,4 +158,87 @@ public void testViewsReturnRecentResults() {
ImmutableList.of(row(1L, "a"), row(1L, "a")),
sql("SELECT * FROM tmp"));
}
+
+ @Test
+ public void testWriteWithOutputSpec() throws NoSuchTableException {
+ Table table = validationCatalog.loadTable(tableIdent);
+ // Drop all records in table to have a fresh start.
+ sql("DELETE FROM %s", tableName);
+ table.refresh();
+
+ final int originalSpecId = table.spec().specId();
+ table.updateSpec().addField("data").commit();
+
+ table.refresh();
Review Comment:
I think this is not necessary?
##########
spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionedWrites.java:
##########
@@ -157,4 +158,87 @@ public void testViewsReturnRecentResults() {
ImmutableList.of(row(1L, "a"), row(1L, "a")),
sql("SELECT * FROM tmp"));
}
+
+ @Test
+ public void testWriteWithOutputSpec() throws NoSuchTableException {
+ Table table = validationCatalog.loadTable(tableIdent);
+ // Drop all records in table to have a fresh start.
+ sql("DELETE FROM %s", tableName);
+ table.refresh();
+
+ final int originalSpecId = table.spec().specId();
+ table.updateSpec().addField("data").commit();
+
+ table.refresh();
+ sql("REFRESH TABLE %s", tableName);
+
+ // By default, we write to the current spec.
+ sql("INSERT INTO TABLE %s VALUES (10, 'a')", tableName);
Review Comment:
Can we do this by dataframe, like below? That way we may not need to
refresh in SQL, and also test can be more consistent, as now its some inserts
by DF, others by SQL
##########
spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionedWrites.java:
##########
@@ -157,4 +158,87 @@ public void testViewsReturnRecentResults() {
ImmutableList.of(row(1L, "a"), row(1L, "a")),
sql("SELECT * FROM tmp"));
}
+
+ @Test
+ public void testWriteWithOutputSpec() throws NoSuchTableException {
+ Table table = validationCatalog.loadTable(tableIdent);
+ // Drop all records in table to have a fresh start.
+ sql("DELETE FROM %s", tableName);
Review Comment:
May be able to drop following refresh as well then, if we can remove that?
--
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]