You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2022/04/29 15:14:24 UTC

[GitHub] [hive] lcspinter opened a new pull request, #3259: HIVE-26190: Implement create iceberg table with metadata location

lcspinter opened a new pull request, #3259:
URL: https://github.com/apache/hive/pull/3259

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/Hive/HowToContribute
     2. Ensure that you have created an issue on the Hive project JIRA: https://issues.apache.org/jira/projects/HIVE/summary
     3. Ensure you have added or run the appropriate tests for your PR: 
     4. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]HIVE-XXXXX:  Your PR title ...'.
     5. Be sure to keep the PR description updated to reflect all changes.
     6. Please write your PR title to summarize what this PR proposes.
     7. If possible, provide a concise example to reproduce the issue for a faster review.
   
   -->
   
   ### What changes were proposed in this pull request?
   Provide support for creating iceberg tables using existing metadata
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   To be able to reuse any metadata. 
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   `CREATE TABLE icebergTbl STORED BY ICEBERG TBLPROPERTIES('metadata_location'='some_location')` is now supported on Hive Catalog tables.
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description, screenshot and/or a reproducable example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Hive versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   Manual test, unit test
   


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r865730027


##########
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java:
##########
@@ -1422,6 +1422,28 @@ public void testAuthzURI() throws TException, InterruptedException, URISyntaxExc
     Assert.assertEquals("iceberg://" + hmsTable.getDbName() + "/" + hmsTable.getTableName(), uriForAuth.toString());
   }
 
+  @Test
+  public void testCreateTableWithMetadataLocation() throws IOException {
+    Assume.assumeTrue("Create with metadata location is only supported for Hive Catalog tables",
+        testTableType.equals(TestTables.TestTableType.HIVE_CATALOG));
+    TableIdentifier sourceIdentifier = TableIdentifier.of("default", "source");
+    Table sourceTable =
+        testTables.createTable(shell, sourceIdentifier.name(), HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+            PartitionSpec.unpartitioned(), FileFormat.PARQUET, Collections.emptyList(), 1,
+            ImmutableMap.<String, String>builder().put(InputFormatConfig.EXTERNAL_TABLE_PURGE, "FALSE").build());
+    testTables.appendIcebergTable(shell.getHiveConf(), sourceTable, FileFormat.PARQUET, null,
+        HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+    String metadataLocation = ((BaseTable) sourceTable).operations().current().metadataFileLocation();
+    shell.executeStatement("DROP TABLE " + sourceIdentifier.name());
+    TableIdentifier targetIdentifier = TableIdentifier.of("default", "target");
+    Table targetTable =
+        testTables.createTable(shell, targetIdentifier.name(), HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+            PartitionSpec.unpartitioned(), FileFormat.PARQUET, Collections.emptyList(), 1,
+            ImmutableMap.<String, String>builder().put("metadata_location", metadataLocation).build()
+        );
+    Assert.assertEquals(metadataLocation, ((BaseTable) targetTable).operations().current().metadataFileLocation());

Review Comment:
   Could we run a query against the table, or use Iceberg api to read data from the table, to see if the data is correct?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r862641625


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/InputFormatConfig.java:
##########
@@ -78,6 +78,7 @@ private InputFormatConfig() {
   public static final String CTAS_TABLE_NAME = "iceberg.mr.ctas.table.name";
   public static final String SELECTED_COLUMNS = "iceberg.mr.selected.columns";
   public static final String EXTERNAL_TABLE_PURGE = "external.table.purge";
+  public static final String METADATA_LOCATION = "metadata_location";

Review Comment:
   This feels problematic to me, as it is already stored in the HiveTableOperations, let's talk about the possible solutions



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r865729109


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -196,9 +201,15 @@ public void commitCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTabl
       if (Catalogs.hiveCatalog(conf, catalogProperties)) {
         catalogProperties.put(TableProperties.ENGINE_HIVE_ENABLED, true);
       }
-
-      Catalogs.createTable(conf, catalogProperties);
+      String metadataLocation = hmsTable.getParameters().get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP);

Review Comment:
   Could we store the location in a `HiveIcebegMetaHook` attribute instead of sending it to HMS?



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] lcspinter commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
lcspinter commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r866015481


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -183,6 +183,11 @@ public void preCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTable)
     catalogProperties.put(InputFormatConfig.TABLE_SCHEMA, SchemaParser.toJson(schema));
     catalogProperties.put(InputFormatConfig.PARTITION_SPEC, PartitionSpecParser.toJson(spec));
     setCommonHmsTablePropertiesForIceberg(hmsTable);
+
+    hmsTable.getParameters().computeIfPresent(BaseMetastoreTableOperations.METADATA_LOCATION_PROP, (k, v) -> {

Review Comment:
   Yes, you're right. Previously I had some code in the mapping function and I forgot the refactor it. 



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] lcspinter commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
lcspinter commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r866023493


##########
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java:
##########
@@ -1422,6 +1422,28 @@ public void testAuthzURI() throws TException, InterruptedException, URISyntaxExc
     Assert.assertEquals("iceberg://" + hmsTable.getDbName() + "/" + hmsTable.getTableName(), uriForAuth.toString());
   }
 
+  @Test
+  public void testCreateTableWithMetadataLocation() throws IOException {
+    Assume.assumeTrue("Create with metadata location is only supported for Hive Catalog tables",
+        testTableType.equals(TestTables.TestTableType.HIVE_CATALOG));
+    TableIdentifier sourceIdentifier = TableIdentifier.of("default", "source");
+    Table sourceTable =
+        testTables.createTable(shell, sourceIdentifier.name(), HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+            PartitionSpec.unpartitioned(), FileFormat.PARQUET, Collections.emptyList(), 1,
+            ImmutableMap.<String, String>builder().put(InputFormatConfig.EXTERNAL_TABLE_PURGE, "FALSE").build());
+    testTables.appendIcebergTable(shell.getHiveConf(), sourceTable, FileFormat.PARQUET, null,
+        HiveIcebergStorageHandlerTestUtils.CUSTOMER_RECORDS);
+    String metadataLocation = ((BaseTable) sourceTable).operations().current().metadataFileLocation();
+    shell.executeStatement("DROP TABLE " + sourceIdentifier.name());
+    TableIdentifier targetIdentifier = TableIdentifier.of("default", "target");
+    Table targetTable =
+        testTables.createTable(shell, targetIdentifier.name(), HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+            PartitionSpec.unpartitioned(), FileFormat.PARQUET, Collections.emptyList(), 1,
+            ImmutableMap.<String, String>builder().put("metadata_location", metadataLocation).build()
+        );
+    Assert.assertEquals(metadataLocation, ((BaseTable) targetTable).operations().current().metadataFileLocation());

Review Comment:
   Good idea, I will add some data validation as well. 



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] lcspinter commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
lcspinter commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r866023092


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -196,9 +201,15 @@ public void commitCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTabl
       if (Catalogs.hiveCatalog(conf, catalogProperties)) {
         catalogProperties.put(TableProperties.ENGINE_HIVE_ENABLED, true);
       }
-
-      Catalogs.createTable(conf, catalogProperties);
+      String metadataLocation = hmsTable.getParameters().get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP);

Review Comment:
   I could extend the `HiveMetaHook` interface with an additional `boolean createHMSTableInHook()` that could return `true` if the location property is present. This way the `HiveMetastoreClient` could also evaluate the need of creating the hms table in place or leaving it for the hook. What do you say? 



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r862641625


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/InputFormatConfig.java:
##########
@@ -78,6 +78,7 @@ private InputFormatConfig() {
   public static final String CTAS_TABLE_NAME = "iceberg.mr.ctas.table.name";
   public static final String SELECTED_COLUMNS = "iceberg.mr.selected.columns";
   public static final String EXTERNAL_TABLE_PURGE = "external.table.purge";
+  public static final String METADATA_LOCATION = "metadata_location";

Review Comment:
   This feels problematic to me, as it is already stored in the HiveTableOperations



##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/InputFormatConfig.java:
##########
@@ -78,6 +78,7 @@ private InputFormatConfig() {
   public static final String CTAS_TABLE_NAME = "iceberg.mr.ctas.table.name";
   public static final String SELECTED_COLUMNS = "iceberg.mr.selected.columns";
   public static final String EXTERNAL_TABLE_PURGE = "external.table.purge";
+  public static final String METADATA_LOCATION = "metadata_location";

Review Comment:
   This feels problematic to me, as it is already stored in the HiveTableOperations, let's talk about this



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r865722414


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/Catalogs.java:
##########
@@ -137,26 +137,12 @@ private static Table loadTable(Configuration conf, String tableIdentifier, Strin
    * @return the created Iceberg table
    */
   public static Table createTable(Configuration conf, Properties props) {
-    String schemaString = props.getProperty(InputFormatConfig.TABLE_SCHEMA);
-    Preconditions.checkNotNull(schemaString, "Table schema not set");
-    Schema schema = SchemaParser.fromJson(props.getProperty(InputFormatConfig.TABLE_SCHEMA));
-
-    String specString = props.getProperty(InputFormatConfig.PARTITION_SPEC);
-    PartitionSpec spec = PartitionSpec.unpartitioned();
-    if (specString != null) {
-      spec = PartitionSpecParser.fromJson(schema, specString);
-    }
-
+    Schema schema = getSchema(props);
+    PartitionSpec spec = getPartitionSpec(props, schema);
     String location = props.getProperty(LOCATION);
     String catalogName = props.getProperty(InputFormatConfig.CATALOG_NAME);
 
-    // Create a table property map without the controlling properties
-    Map<String, String> map = Maps.newHashMapWithExpectedSize(props.size());
-    for (Object key : props.keySet()) {
-      if (!PROPERTIES_TO_REMOVE.contains(key)) {
-        map.put(key.toString(), props.get(key).toString());
-      }
-    }
+    Map<String, String> map = getIcebergTableProperties(props);

Review Comment:
   nit:filterIcebergTableProperties?
   We do not use `get` in Iceberg code path, so we conform the Iceberg coding standards



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r865722866


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/Catalogs.java:
##########
@@ -137,26 +137,12 @@ private static Table loadTable(Configuration conf, String tableIdentifier, Strin
    * @return the created Iceberg table
    */
   public static Table createTable(Configuration conf, Properties props) {
-    String schemaString = props.getProperty(InputFormatConfig.TABLE_SCHEMA);
-    Preconditions.checkNotNull(schemaString, "Table schema not set");
-    Schema schema = SchemaParser.fromJson(props.getProperty(InputFormatConfig.TABLE_SCHEMA));
-
-    String specString = props.getProperty(InputFormatConfig.PARTITION_SPEC);
-    PartitionSpec spec = PartitionSpec.unpartitioned();
-    if (specString != null) {
-      spec = PartitionSpecParser.fromJson(schema, specString);
-    }
-
+    Schema schema = getSchema(props);
+    PartitionSpec spec = getPartitionSpec(props, schema);

Review Comment:
   nit: spec(props, schema)



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r862637833


##########
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HiveCatalog.java:
##########
@@ -100,6 +101,11 @@ public void initialize(String inputName, Map<String, String> properties) {
     this.clients = new CachedClientPool(conf, properties);
   }
 
+  @Override
+  public TableBuilder buildTable(TableIdentifier identifier, Schema schema) {
+    return new HiveCatalog.HiveCatalogTableBuilder(identifier, schema);

Review Comment:
   nit: We can use:
   ```
   return new HiveCatalogTableBuilder(identifier, schema);
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r865722634


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/Catalogs.java:
##########
@@ -137,26 +137,12 @@ private static Table loadTable(Configuration conf, String tableIdentifier, Strin
    * @return the created Iceberg table
    */
   public static Table createTable(Configuration conf, Properties props) {
-    String schemaString = props.getProperty(InputFormatConfig.TABLE_SCHEMA);
-    Preconditions.checkNotNull(schemaString, "Table schema not set");
-    Schema schema = SchemaParser.fromJson(props.getProperty(InputFormatConfig.TABLE_SCHEMA));
-
-    String specString = props.getProperty(InputFormatConfig.PARTITION_SPEC);
-    PartitionSpec spec = PartitionSpec.unpartitioned();
-    if (specString != null) {
-      spec = PartitionSpecParser.fromJson(schema, specString);
-    }
-
+    Schema schema = getSchema(props);

Review Comment:
   nit: schema(props)



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r865726519


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -196,9 +201,15 @@ public void commitCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTabl
       if (Catalogs.hiveCatalog(conf, catalogProperties)) {
         catalogProperties.put(TableProperties.ENGINE_HIVE_ENABLED, true);
       }
-
-      Catalogs.createTable(conf, catalogProperties);
+      String metadataLocation = hmsTable.getParameters().get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP);

Review Comment:
   nit: newline after block close



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r862640923


##########
iceberg/iceberg-handler/src/test/java/org/apache/iceberg/mr/hive/TestHiveIcebergStorageHandlerNoScan.java:
##########
@@ -1422,6 +1422,28 @@ public void testAuthzURI() throws TException, InterruptedException, URISyntaxExc
     Assert.assertEquals("iceberg://" + hmsTable.getDbName() + "/" + hmsTable.getTableName(), uriForAuth.toString());
   }
 
+  @Test
+  public void testCreateTableWithMetadataLocation() throws IOException {
+    Assume.assumeTrue("Create with metadata location is only supported for Hive Catalog tables",
+        testTableType.equals(TestTables.TestTableType.HIVE_CATALOG));
+    TableIdentifier sourceIdentifier = TableIdentifier.of("default", "source");
+    Table sourceTable =
+        testTables.createTable(shell, sourceIdentifier.name(), HiveIcebergStorageHandlerTestUtils.CUSTOMER_SCHEMA,
+            PartitionSpec.unpartitioned(), FileFormat.PARQUET, Collections.emptyList(), 1,
+            ImmutableMap.<String, String>builder().put(InputFormatConfig.EXTERNAL_TABLE_PURGE, "FALSE").build());

Review Comment:
   ```
   ImmutableMap.of(InputFormatConfig.EXTERNAL_TABLE_PURGE, "FALSE")
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] lcspinter merged pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
lcspinter merged PR #3259:
URL: https://github.com/apache/hive/pull/3259


-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r865725793


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -183,6 +183,11 @@ public void preCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTable)
     catalogProperties.put(InputFormatConfig.TABLE_SCHEMA, SchemaParser.toJson(schema));
     catalogProperties.put(InputFormatConfig.PARTITION_SPEC, PartitionSpecParser.toJson(spec));
     setCommonHmsTablePropertiesForIceberg(hmsTable);
+
+    hmsTable.getParameters().computeIfPresent(BaseMetastoreTableOperations.METADATA_LOCATION_PROP, (k, v) -> {

Review Comment:
   is this equivalent with this:
   ```
   if (hmsTable.getParameters().get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP) != null) {
     hmsTable.getParameters().put(CREATE_HMS_TABLE_IN_HOOK, "true");
   }
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] pvary commented on a diff in pull request #3259: HIVE-26190: Implement create iceberg table with metadata location

Posted by GitBox <gi...@apache.org>.
pvary commented on code in PR #3259:
URL: https://github.com/apache/hive/pull/3259#discussion_r865725793


##########
iceberg/iceberg-handler/src/main/java/org/apache/iceberg/mr/hive/HiveIcebergMetaHook.java:
##########
@@ -183,6 +183,11 @@ public void preCreateTable(org.apache.hadoop.hive.metastore.api.Table hmsTable)
     catalogProperties.put(InputFormatConfig.TABLE_SCHEMA, SchemaParser.toJson(schema));
     catalogProperties.put(InputFormatConfig.PARTITION_SPEC, PartitionSpecParser.toJson(spec));
     setCommonHmsTablePropertiesForIceberg(hmsTable);
+
+    hmsTable.getParameters().computeIfPresent(BaseMetastoreTableOperations.METADATA_LOCATION_PROP, (k, v) -> {

Review Comment:
   is this equivalent with this:
   ```
   if (hmsTable.getParameters().computeIfPresent(BaseMetastoreTableOperations.METADATA_LOCATION_PROP) != null) {
     hmsTable.getParameters().put(CREATE_HMS_TABLE_IN_HOOK, "true");
   }
   ```



-- 
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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org