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 2021/04/19 13:11:18 UTC

[GitHub] [hive] kgyrtkirk opened a new pull request #2191: HIVE-24920 trans ext

kgyrtkirk opened a new pull request #2191:
URL: https://github.com/apache/hive/pull/2191


   <!--
   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?
   <!--
   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?
   <!--
   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?
   <!--
   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.
   -->
   


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

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] kgyrtkirk merged pull request #2191: HIVE-24920: TRANSLATED_TO_EXTERNAL tables may write to the same location

Posted by GitBox <gi...@apache.org>.
kgyrtkirk merged pull request #2191:
URL: https://github.com/apache/hive/pull/2191


   


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

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] nrg4878 commented on a change in pull request #2191: HIVE-24920: TRANSLATED_TO_EXTERNAL tables may write to the same location

Posted by GitBox <gi...@apache.org>.
nrg4878 commented on a change in pull request #2191:
URL: https://github.com/apache/hive/pull/2191#discussion_r629433082



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDefaultTransformer.java
##########
@@ -85,6 +86,7 @@ public MetastoreDefaultTransformer(IHMSHandler handler) throws HiveMetaException
     this.hmsHandler = handler;
     this.defaultCatalog = MetaStoreUtils.getDefaultCatalog(handler.getConf());
     this.isTenantBasedStorage = hmsHandler.getConf().getBoolean(MetastoreConf.ConfVars.ALLOW_TENANT_BASED_STORAGE.getVarname(), false);
+    //    this.xMode = hmsHandler.getConf

Review comment:
       nit: delete please.

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDefaultTransformer.java
##########
@@ -558,6 +566,39 @@ public MetastoreDefaultTransformer(IHMSHandler handler) throws HiveMetaException
     return ret;
   }
 
+  static enum TableLocationStrategy {
+    seqsuffix {
+      @Override
+      Path getLocation(IHMSHandler hmsHandler, Database db, Table table, int idx) throws MetaException {
+        if (idx == 0) {
+          return getDefaultPath(hmsHandler, db, table.getTableName());
+        }
+        return getDefaultPath(hmsHandler, db, table.getTableName() + "-" + idx);

Review comment:
       I have a mild concern about this convention. It might be confusing to use a suffix. would a prefix serve us better? with the latter scheme, the original table name can still be preserved?
   create table test;
   alter table rename test to test1;
   create table test; --> test is now at location test-0
   create table test-0; --> test-0 is now at location test-1 (would using 0_test-0 be better than using test-1?)

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDefaultTransformer.java
##########
@@ -527,7 +532,9 @@ public MetastoreDefaultTransformer(IHMSHandler handler) throws HiveMetaException
               Partition newPartition = new Partition(partition);
               StorageDescriptor newSd = new StorageDescriptor(partition.getSd());
               if (!processorCapabilities.contains(ACCEPTSUNMODIFIEDMETADATA))
+               {

Review comment:
       nit: extra leading space.




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

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] kgyrtkirk commented on a change in pull request #2191: HIVE-24920: TRANSLATED_TO_EXTERNAL tables may write to the same location

Posted by GitBox <gi...@apache.org>.
kgyrtkirk commented on a change in pull request #2191:
URL: https://github.com/apache/hive/pull/2191#discussion_r637024947



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDefaultTransformer.java
##########
@@ -822,7 +934,7 @@ private Table validateTablePaths(Table table) throws MetaException {
                     + table.getTableName() + ",location:" + tablePath + ",Database's managed warehouse:" + dbLocation);
           }
         } else {
-          if (FileUtils.isSubdirectory(whRootPath.toString(), tablePath.toString())) {
+          if (isExternalWarehouseSet() && FileUtils.isSubdirectory(whRootPath.toString(), tablePath.toString())) {

Review comment:
       I just bumped into this while fixing this issue - in case the  `externalWarehouse`  is not set both external and managed tables are placed at the same location with the default configs:
   ```
   create external table te (a integer); // file:/data/hive/warehouse/t
   desc formatted te;
   [...]
   | Location:                     | file:/data/hive/warehouse/te                       | NULL                                               |
   | Table Parameters:             | NULL                                               | NULL                                               |
   |                               | EXTERNAL                                           | TRUE                                               |
   
   [...]
   create  table tm (a integer);
   desc formatted tm;
   [...]
   | Location:                     | file:/data/hive/warehouse/tm                       | NULL                                               |
   | Table Type:                   | EXTERNAL_TABLE                                     | NULL                                               |
   |                               | EXTERNAL                                           | TRUE                                               |
   |                               | TRANSLATED_TO_EXTERNAL                             | TRUE                                               |
   [...]
   ```
   
   the root cause of this is that
   * in case the ext wh is not set - it will be the default whroot:
   https://github.com/apache/hive/blob/bf608ceadaf571440b0ead079adab674400fc956/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java#L209
   * managed location for both default and non-default dbs are under wh by default
   
   since the managed location is the same I don't think checking that would make sense...
   
   don't you think that the current change aligns with the existing decisions/behaiour/etc in the above case?




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

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] kgyrtkirk commented on pull request #2191: HIVE-24920: TRANSLATED_TO_EXTERNAL tables may write to the same location

Posted by GitBox <gi...@apache.org>.
kgyrtkirk commented on pull request #2191:
URL: https://github.com/apache/hive/pull/2191#issuecomment-824833336


   @nrg4878 could you please take a look?


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

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] nrg4878 commented on a change in pull request #2191: HIVE-24920: TRANSLATED_TO_EXTERNAL tables may write to the same location

Posted by GitBox <gi...@apache.org>.
nrg4878 commented on a change in pull request #2191:
URL: https://github.com/apache/hive/pull/2191#discussion_r636924592



##########
File path: ql/src/test/results/clientnegative/translated_external_rename.q.out
##########
@@ -0,0 +1,22 @@
+PREHOOK: query: create external table t (a integer)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t
+POSTHOOK: query: create external table t (a integer)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t
+PREHOOK: query: insert into t values(1)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values(1)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.a SCRIPT []
+PREHOOK: query: alter table t rename to t2
+PREHOOK: type: ALTERTABLE_RENAME
+PREHOOK: Input: default@t
+PREHOOK: Output: default@t
+FAILED: Execution Error, return code 40013 from org.apache.hadoop.hive.ql.ddl.DDLTask. Unable to alter table. java.lang.NullPointerException

Review comment:
       nit: Looks like the exception is NullPointerException. Not a showstopper but I would expect this to be a MetaException

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDefaultTransformer.java
##########
@@ -822,7 +934,7 @@ private Table validateTablePaths(Table table) throws MetaException {
                     + table.getTableName() + ",location:" + tablePath + ",Database's managed warehouse:" + dbLocation);
           }
         } else {
-          if (FileUtils.isSubdirectory(whRootPath.toString(), tablePath.toString())) {
+          if (isExternalWarehouseSet() && FileUtils.isSubdirectory(whRootPath.toString(), tablePath.toString())) {

Review comment:
       So we only care that an external table is outside the managed warehouse root. It does not have to be within the external warehouse. So even if external warehouse isnt set, we shouldnt have to reject a path so long as it is not in the managed warehouse root.




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

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] kgyrtkirk commented on a change in pull request #2191: HIVE-24920: TRANSLATED_TO_EXTERNAL tables may write to the same location

Posted by GitBox <gi...@apache.org>.
kgyrtkirk commented on a change in pull request #2191:
URL: https://github.com/apache/hive/pull/2191#discussion_r629526765



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetastoreDefaultTransformer.java
##########
@@ -558,6 +566,39 @@ public MetastoreDefaultTransformer(IHMSHandler handler) throws HiveMetaException
     return ret;
   }
 
+  static enum TableLocationStrategy {
+    seqsuffix {
+      @Override
+      Path getLocation(IHMSHandler hmsHandler, Database db, Table table, int idx) throws MetaException {
+        if (idx == 0) {
+          return getDefaultPath(hmsHandler, db, table.getTableName());
+        }
+        return getDefaultPath(hmsHandler, db, table.getTableName() + "-" + idx);

Review comment:
       there is logic behind this naming schema as well - I think it's better to have an option to choose this as well ; I've added this as `seqprefix`
   I've modified to use `_` as the separator
   
   I wonder which one should be the default behaviour? "seqsuffix", "seqprefix" or "prohibit"
   I'm fine with either the prefix or suffix one; but I would like to avoid prohibit as the default




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

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] kgyrtkirk commented on a change in pull request #2191: HIVE-24920: TRANSLATED_TO_EXTERNAL tables may write to the same location

Posted by GitBox <gi...@apache.org>.
kgyrtkirk commented on a change in pull request #2191:
URL: https://github.com/apache/hive/pull/2191#discussion_r637025131



##########
File path: ql/src/test/results/clientnegative/translated_external_rename.q.out
##########
@@ -0,0 +1,22 @@
+PREHOOK: query: create external table t (a integer)
+PREHOOK: type: CREATETABLE
+PREHOOK: Output: database:default
+PREHOOK: Output: default@t
+POSTHOOK: query: create external table t (a integer)
+POSTHOOK: type: CREATETABLE
+POSTHOOK: Output: database:default
+POSTHOOK: Output: default@t
+PREHOOK: query: insert into t values(1)
+PREHOOK: type: QUERY
+PREHOOK: Input: _dummy_database@_dummy_table
+PREHOOK: Output: default@t
+POSTHOOK: query: insert into t values(1)
+POSTHOOK: type: QUERY
+POSTHOOK: Input: _dummy_database@_dummy_table
+POSTHOOK: Output: default@t
+POSTHOOK: Lineage: t.a SCRIPT []
+PREHOOK: query: alter table t rename to t2
+PREHOOK: type: ALTERTABLE_RENAME
+PREHOOK: Input: default@t
+PREHOOK: Output: default@t
+FAILED: Execution Error, return code 40013 from org.apache.hadoop.hive.ql.ddl.DDLTask. Unable to alter table. java.lang.NullPointerException

Review comment:
       oops; I just fixed it! thank you!




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

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