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


##########
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:
   > I personally really don't like working with mocks, so I understand what 
you mean
   
   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`).
   
   > I would consider adding some test that does get run through the CI test 
suite, to ensure that any changes that are made in the API are made against the 
Glue catalog
   
   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. 
   
   > Maybe adding GlueCatalog to the existing CatalogTests suite would be 
beneficial in the long run? Something to consider.
   
   Yes, I think adding GlueCatalog to the existing CatalogTests suite would be 
beneficial. I can publish a separate PR for the same.
   
   Please let me know your thoughts.



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