rdblue commented on code in PR #9131: URL: https://github.com/apache/iceberg/pull/9131#discussion_r1414414566
########## spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/source/TestSnapshotSelection.java: ########## @@ -425,16 +426,56 @@ public void testSnapshotSelectionByBranchWithSchemaChange() throws IOException { // Deleting a column to indicate schema change table.updateSchema().deleteColumn("data").commit(); - // The data should have the deleted column as it was captured in an earlier snapshot. - Dataset<Row> deletedColumnBranchSnapshotResult = - spark.read().format("iceberg").option("branch", "branch").load(tableLocation); - List<SimpleRecord> deletedColumnBranchSnapshotRecords = - deletedColumnBranchSnapshotResult - .orderBy("id") - .as(Encoders.bean(SimpleRecord.class)) - .collectAsList(); - Assert.assertEquals( - "Current snapshot rows should match", expectedRecords, deletedColumnBranchSnapshotRecords); + // The data should not have the deleted column + Assertions.assertThat( + spark + .read() + .format("iceberg") + .option("branch", "branch") + .load(tableLocation) + .orderBy("id") + .collectAsList()) + .containsExactly( + new GenericRowWithSchema(new Object[] {1}, null), + new GenericRowWithSchema(new Object[] {2}, null), + new GenericRowWithSchema(new Object[] {3}, null)); + + // re-introducing the column should not let the data re-appear + table.updateSchema().addColumn("data", Types.StringType.get()).commit(); + + Assertions.assertThat( + spark + .read() + .format("iceberg") + .option("branch", "branch") + .load(tableLocation) + .orderBy("id") + .as(Encoders.bean(SimpleRecord.class)) + .collectAsList()) + .containsExactly( + new SimpleRecord(1, null), new SimpleRecord(2, null), new SimpleRecord(3, null)); + + // writing new records into the branch should work with the re-introduced column Review Comment: I don't think this is an appropriate place for the write test. It should be a new test case because this case tests the schema that is used when reading. In addition, the test case should test writing when the current snapshot for a branch has a different schema than the table schema. With the column added back, the schemas are the same. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org