nastra commented on code in PR #9790: URL: https://github.com/apache/iceberg/pull/9790#discussion_r1502425979
########## spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestMetadataTables.java: ########## @@ -605,43 +597,64 @@ public void testSnapshotReferencesMetatable() throws Exception { .commit(); // Check refs table List<Row> references = spark.sql("SELECT * FROM " + tableName + ".refs").collectAsList(); - Assert.assertEquals("Refs table should return 3 rows", 3, references.size()); + assertThat(references).as("Refs table should return 3 rows").hasSize(3); List<Row> branches = spark.sql("SELECT * FROM " + tableName + ".refs WHERE type='BRANCH'").collectAsList(); - Assert.assertEquals("Refs table should return 2 branches", 2, branches.size()); + assertThat(branches).as("Refs table should return 2 branches").hasSize(2); List<Row> tags = spark.sql("SELECT * FROM " + tableName + ".refs WHERE type='TAG'").collectAsList(); - Assert.assertEquals("Refs table should return 1 tag", 1, tags.size()); + assertThat(tags).as("Refs table should return 1 tag").hasSize(1); // Check branch entries in refs table List<Row> mainBranch = spark .sql("SELECT * FROM " + tableName + ".refs WHERE name = 'main' AND type='BRANCH'") .collectAsList(); - Assert.assertEquals("main", mainBranch.get(0).getAs("name")); - Assert.assertEquals("BRANCH", mainBranch.get(0).getAs("type")); - Assert.assertEquals(currentSnapshotId, mainBranch.get(0).getAs("snapshot_id")); + assertThat(mainBranch).hasSize(1); + assertThat(mainBranch.get(0).schema().fieldNames()) + .containsExactly( + "name", + "type", + "snapshot_id", + "max_reference_age_in_ms", + "min_snapshots_to_keep", + "max_snapshot_age_in_ms"); + assertThat(mainBranch) + .containsExactly(RowFactory.create("main", "BRANCH", currentSnapshotId, null, null, null)); List<Row> testBranch = spark .sql("SELECT * FROM " + tableName + ".refs WHERE name = 'testBranch' AND type='BRANCH'") .collectAsList(); - Assert.assertEquals("testBranch", testBranch.get(0).getAs("name")); - Assert.assertEquals("BRANCH", testBranch.get(0).getAs("type")); - Assert.assertEquals(currentSnapshotId, testBranch.get(0).getAs("snapshot_id")); - Assert.assertEquals(Long.valueOf(10), testBranch.get(0).getAs("max_reference_age_in_ms")); - Assert.assertEquals(Integer.valueOf(20), testBranch.get(0).getAs("min_snapshots_to_keep")); - Assert.assertEquals(Long.valueOf(30), testBranch.get(0).getAs("max_snapshot_age_in_ms")); + assertThat(testBranch).hasSize(1); + assertThat(testBranch.get(0).schema().fieldNames()) + .containsExactly( + "name", + "type", + "snapshot_id", + "max_reference_age_in_ms", + "min_snapshots_to_keep", + "max_snapshot_age_in_ms"); + assertThat(testBranch) + .containsExactly( + RowFactory.create("testBranch", "BRANCH", currentSnapshotId, 10L, 20L, 30L)); // Check tag entries in refs table List<Row> testTag = spark .sql("SELECT * FROM " + tableName + ".refs WHERE name = 'testTag' AND type='TAG'") .collectAsList(); - Assert.assertEquals("testTag", testTag.get(0).getAs("name")); - Assert.assertEquals("TAG", testTag.get(0).getAs("type")); - Assert.assertEquals(currentSnapshotId, testTag.get(0).getAs("snapshot_id")); - Assert.assertEquals(Long.valueOf(50), testTag.get(0).getAs("max_reference_age_in_ms")); + assertThat(testTag).hasSize(1); + assertThat(testTag.get(0).schema().fieldNames()) Review Comment: you could combine this with the previous line: `assertThat(testTag).hasSize(1).first().schema().fieldNames()).containsExactly(...)` please also update all the other checks in this file around branch/tag verification -- 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