wypoon commented on code in PR #5629:
URL: https://github.com/apache/iceberg/pull/5629#discussion_r973474575


##########
spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkTable.java:
##########
@@ -57,4 +61,48 @@ public void testTableEquality() throws NoSuchTableException {
     Assert.assertNotSame("References must be different", table1, table2);
     Assert.assertEquals("Tables must be equivalent", table1, table2);
   }
+
+  @Test
+  public void testTableName() {
+    CatalogManager catalogManager = spark.sessionState().catalogManager();
+    TableCatalog catalog = (TableCatalog) catalogManager.catalog(catalogName);
+
+    for (String fileFormat : Lists.newArrayList("parquet", "orc", "avro")) {
+      for (String tableFormatVersion : Lists.newArrayList("1", "2")) {

Review Comment:
   Now that the file format and Iceberg format version are no longer shown, it 
is not necessary to tests these.



##########
spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/source/TestSparkTable.java:
##########
@@ -57,4 +61,48 @@ public void testTableEquality() throws NoSuchTableException {
     Assert.assertNotSame("References must be different", table1, table2);
     Assert.assertEquals("Tables must be equivalent", table1, table2);
   }
+
+  @Test
+  public void testTableName() {
+    CatalogManager catalogManager = spark.sessionState().catalogManager();
+    TableCatalog catalog = (TableCatalog) catalogManager.catalog(catalogName);
+
+    for (String fileFormat : Lists.newArrayList("parquet", "orc", "avro")) {
+      for (String tableFormatVersion : Lists.newArrayList("1", "2")) {
+        String testTableName =
+            String.format("table_name_test_%s_v%s", fileFormat, 
tableFormatVersion);
+        withTables(
+            () -> {
+              sql(
+                  String.format(
+                      "CREATE TABLE %s USING iceberg TBLPROPERTIES ('%s'='%s', 
'%s'='%s')",
+                      tableName(testTableName),
+                      TableProperties.DEFAULT_FILE_FORMAT,
+                      fileFormat,
+                      TableProperties.FORMAT_VERSION,
+                      tableFormatVersion));
+
+              TableIdentifier icebergIdentifier =
+                  TableIdentifier.of(Namespace.of("default"), testTableName);
+              Identifier sparkIdentifier =
+                  Identifier.of(icebergIdentifier.namespace().levels(), 
icebergIdentifier.name());
+
+              try {
+                // Catalog#loadTable throw NoSuchTableException, however, the 
Action#invoke
+                // does not expect any exceptions to be thrown, thus it 
wrapped inside
+                // RuntimeException.
+                String actualTableName = 
catalog.loadTable(sparkIdentifier).name();
+                String expectedTableName =
+                    String.format("Iceberg %s.%s", catalogName, 
icebergIdentifier);
+                Assert.assertEquals(
+                    "Table name mismatched for (%s file format, %s table 
format version)",

Review Comment:
   Perhaps just "Table name did not match" for the message, since you no longer 
show file format or table format version.



-- 
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]

Reply via email to