kbendick commented on code in PR #4011:
URL: https://github.com/apache/iceberg/pull/4011#discussion_r875064040


##########
aws/src/integration/java/org/apache/iceberg/aws/glue/TestGlueCatalogTable.java:
##########
@@ -368,4 +369,54 @@ public void testColumnCommentsAndParameters() {
     );
     Assert.assertEquals("Columns do not match", expectedColumns, 
actualColumns);
   }
+
+  @Test
+  public void testTablePropsDefinedAtCatalogLevel() {
+    String namespace = createNamespace();
+    String tableName = getRandomName();
+    TableIdentifier tableIdent = TableIdentifier.of(namespace, tableName);
+    ImmutableMap<String, String> catalogProps = ImmutableMap.of(
+        "table-default.key1", "catalog-default-key1",
+        "table-default.key2", "catalog-default-key2",
+        "table-default.key3", "catalog-default-key3",
+        "table-override.key3", "catalog-override-key3",
+        "table-override.key4", "catalog-override-key4",
+        "warehouse", "s3://" + testBucketName + "/" + testPathPrefix);
+
+    glueCatalog.initialize("glue", catalogProps);
+
+    Schema schema = new Schema(
+        NestedField.required(3, "id", Types.IntegerType.get(), "unique ID"),
+        NestedField.required(4, "data", Types.StringType.get())
+    );
+
+    org.apache.iceberg.Table table = glueCatalog.buildTable(tableIdent, schema)
+        .withProperty("key2", "table-key2")
+        .withProperty("key3", "table-key3")
+        .withProperty("key5", "table-key5")
+        .create();
+
+    Assert.assertEquals(
+        "Table defaults set for the catalog must be added to the table 
properties.",
+        "catalog-default-key1",
+        table.properties().get("key1"));
+    Assert.assertEquals(
+        "Table property must override table default properties set at catalog 
level.",
+        "table-key2",
+        table.properties().get("key2"));
+    Assert.assertEquals(
+        "Table property override set at catalog level must override table 
default" +
+            " properties set at catalog level and table property specified.",
+        "catalog-override-key3",
+        table.properties().get("key3"));
+    Assert.assertEquals(
+        "Table override not in table props or defaults should be added to 
table properties",
+        "catalog-override-key4",
+        table.properties().get("key4"));
+    Assert.assertEquals(
+        "Table properties without any catalog level default or override should 
be added to table" +
+            " properties.",
+        "table-key5",
+        table.properties().get("key5"));
+  }

Review Comment:
   > Yes, one more limitation here with mocking the glue client is we cannot 
mock the glue table response with a path for the 
BaseMetastoreTableOperations.METADATA_LOCATION_PROP property (as it starts 
checking for the existence of the file while refreshing the metadata in 
BaseMetastoreTableOperations)
   
   +1 understood. Wondering if we should comment this somewhere. I suppose a 
standalone comment on this PR is sufficient (or maybe in the final squashed git 
PR summarty a small mention of that in the extended message?). But overall +1 
understood. Mocks can't solve everything.
   
   > I have added a test which asserts that the properties API should not 
return an empty map from Glue Catalog when the catalog properties are 
initialised. The processing of the properties in BaseMetastoreCatalog is 
validated by HadoopCatalog and HiveCatalog. Meanwhile, TestGlueCatalogTable 
should check the actual behaviour for GlueCatalog.
   
   +1 
   
   > Yes, I think adding GlueCatalog to the existing CatalogTests suite would 
be beneficial. I can publish a separate PR for the same.
   
   Major +1. That would be really beneficial. Even if it involves some mocks 
(right now there's backing catalog, which for REST we use JDBC via the 
`CatalogAdaptor`.
   
   Even just having some mocks there one time would make it easy for people who 
aren't super knowledgable in Glue to add tests that hit multiple catalogs 
without knowing the details of all of them (to some degree or with review).
   
   Definitely for a separate PR though =)



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