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 2020/06/13 08:15:56 UTC

[GitHub] [hive] shameersss1 opened a new pull request #1105: HIVE-22957: Add Option For Predicate Filtering In MSCK REPAIR TABLE Command

shameersss1 opened a new pull request #1105:
URL: https://github.com/apache/hive/pull/1105


   


----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -734,6 +734,21 @@ dropPartitionOperator
     EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN
     ;
 
+filterPartitionSpec
+    :
+    LPAREN filterPartitionVal (COMMA  filterPartitionVal )* RPAREN -> ^(TOK_PARTSPEC filterPartitionVal +)
+    ;
+
+filterPartitionVal
+    :
+    identifier filterPartitionOperator constant -> ^(TOK_PARTVAL identifier filterPartitionOperator constant)
+    ;
+
+filterPartitionOperator
+    :
+    EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN | KW_LIKE

Review comment:
       There is one slight difference apart from the LIKE operator, dropPartitionSpec expects PARTITON keyword, But since in MSCK we already have a PARTITONS keyword in the syntax it will cause a problem.
   




----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
##########
@@ -1942,8 +1942,8 @@ metastoreCheck
 @after { popMsg(state); }
     : KW_MSCK (repair=KW_REPAIR)?
       (KW_TABLE tableName
-        (opt=(KW_ADD|KW_DROP|KW_SYNC) (parts=KW_PARTITIONS) (filterPartitionSpec)?)?)
-    -> ^(TOK_MSCK $repair? tableName? $opt? (filterPartitionSpec)?)
+        (opt=(KW_ADD|KW_DROP|KW_SYNC) (parts=KW_PARTITIONS)? (dropPartitionSpec)?)?)

Review comment:
       Option 2 looks good, Option 1 will change the current syntax.
   Fixed.

##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -720,7 +720,7 @@ partitionVal
 
 dropPartitionSpec
     :
-    KW_PARTITION
+    KW_PARTITION | KW_PARTITIONS

Review comment:
       As discussed above!

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java
##########
@@ -71,10 +71,15 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
     Map<Integer, List<ExprNodeGenericFuncDesc>> partitionSpecs = ParseUtils.getFullPartitionSpecs(root, table, conf, false);
     byte[] filterExp = null;
     if (partitionSpecs != null & !partitionSpecs.isEmpty()) {
-      // explicitly set expression proxy class to PartitionExpressionForMetastore since we intend to use the
+      // expression proxy class needs to be PartitionExpressionForMetastore since we intend to use the
       // filterPartitionsByExpr of PartitionExpressionForMetastore for partition pruning down the line.
-      conf.set(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname(),
-          PartitionExpressionForMetastore.class.getCanonicalName());
+      // Bail out early if expressionProxyClass is not configured properly.
+      String expressionProxyClass = conf.get(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname());
+      if (expressionProxyClass == null || expressionProxyClass.isEmpty() ||
+          !expressionProxyClass.equals(PartitionExpressionForMetastore.class.getCanonicalName())) {

Review comment:
       Fixed!




----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java
##########
@@ -63,13 +67,24 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
     }
 
     Table table = getTable(tableName);
-    List<Map<String, String>> specs = getPartitionSpecs(table, root);
+    Map<Integer, List<ExprNodeGenericFuncDesc>> partitionSpecs = getFullPartitionSpecs(root, table, conf, false);
+    byte[] filterExp = null;
+    if (partitionSpecs != null & !partitionSpecs.isEmpty()) {
+      // explicitly set expression proxy class to PartitionExpressionForMetastore since we intend to use the
+      // filterPartitionsByExpr of PartitionExpressionForMetastore for partition pruning down the line.
+      conf.set(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname(),

Review comment:
       Done!

##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -734,6 +734,21 @@ dropPartitionOperator
     EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN
     ;
 
+filterPartitionSpec
+    :
+    LPAREN filterPartitionVal (COMMA  filterPartitionVal )* RPAREN -> ^(TOK_PARTSPEC filterPartitionVal +)
+    ;
+
+filterPartitionVal
+    :
+    identifier filterPartitionOperator constant -> ^(TOK_PARTVAL identifier filterPartitionOperator constant)
+    ;
+
+filterPartitionOperator
+    :
+    EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN | KW_LIKE

Review comment:
       Done!




----------------------------------------------------------------
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 #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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


   Hey @shameersss1 !
   
   yes...actually my eyes have found the method you've moved a bit wierd (especially [here](
   https://github.com/apache/hive/blob/5a54752f8f1964b266a25a47f3d05d894806dc78/ql/src/java/org/apache/hadoop/hive/ql/ddl/table/partition/drop/AbstractDropPartitionAnalyzer.java#L214) ) and I wanted to take another look...but that thing was clearly there before your patch :)
   


----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -240,40 +243,27 @@ void checkTable(String catName, String dbName, String tableName,
     }
 
     PartitionIterable parts;
-    boolean findUnknownPartitions = true;
 
     if (isPartitioned(table)) {
-      if (partitions == null || partitions.isEmpty()) {
+      if (filterExp != null) {
+        List<Partition> results = new ArrayList<>();
+        getPartitionListByFilterExp(getMsc(), table, filterExp,

Review comment:
       I though this initially but it becomes difficult to serialize filter exp once we move out of ql code, Hence did the kyro stuff in the initial stage




----------------------------------------------------------------
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] shameersss1 edited a comment on pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

Posted by GitBox <gi...@apache.org>.
shameersss1 edited a comment on pull request #1105:
URL: https://github.com/apache/hive/pull/1105#issuecomment-644528808


   @jcamachor Could you please review?


----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java
##########
@@ -63,13 +67,24 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
     }
 
     Table table = getTable(tableName);
-    List<Map<String, String>> specs = getPartitionSpecs(table, root);
+    Map<Integer, List<ExprNodeGenericFuncDesc>> partitionSpecs = getFullPartitionSpecs(root, table, conf, false);
+    byte[] filterExp = null;
+    if (partitionSpecs != null & !partitionSpecs.isEmpty()) {
+      // explicitly set expression proxy class to PartitionExpressionForMetastore since we intend to use the
+      // filterPartitionsByExpr of PartitionExpressionForMetastore for partition pruning down the line.
+      conf.set(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname(),
+          PartitionExpressionForMetastore.class.getCanonicalName());
+      // fetch the first value of partitionSpecs map since it will always have one key, value pair
+      filterExp = SerializationUtilities.serializeExpressionToKryo(

Review comment:
       PartitionPruner and msc.listPartitionsByExpr() expects serialized byte array, Hence it is required to flatten out.

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
##########
@@ -837,6 +844,118 @@ public static void checkColumnName(String columnName) throws SemanticException {
     return colList;
   }
 
+  /**
+   * Get the partition specs from the tree. This stores the full specification
+   * with the comparator operator into the output list.
+   *
+   * @return Map of partitions by prefix length. Most of the time prefix length will
+   *         be the same for all partition specs, so we can just OR the expressions.
+   */
+  public static Map<Integer, List<ExprNodeGenericFuncDesc>> getFullPartitionSpecs(

Review comment:
       Fixed!




----------------------------------------------------------------
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 #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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


   


----------------------------------------------------------------
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 #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -240,40 +243,27 @@ void checkTable(String catName, String dbName, String tableName,
     }
 
     PartitionIterable parts;
-    boolean findUnknownPartitions = true;
 
     if (isPartitioned(table)) {
-      if (partitions == null || partitions.isEmpty()) {
+      if (filterExp != null) {
+        List<Partition> results = new ArrayList<>();
+        getPartitionListByFilterExp(getMsc(), table, filterExp,

Review comment:
       yeah I understand...sometimes we have to cook from what we have :D
   
   ![gif](https://media.giphy.com/media/LVBH3rg1BUROw/giphy.gif)
   
   




----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java
##########
@@ -63,13 +67,24 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
     }
 
     Table table = getTable(tableName);
-    List<Map<String, String>> specs = getPartitionSpecs(table, root);
+    Map<Integer, List<ExprNodeGenericFuncDesc>> partitionSpecs = getFullPartitionSpecs(root, table, conf, false);
+    byte[] filterExp = null;
+    if (partitionSpecs != null & !partitionSpecs.isEmpty()) {
+      // explicitly set expression proxy class to PartitionExpressionForMetastore since we intend to use the
+      // filterPartitionsByExpr of PartitionExpressionForMetastore for partition pruning down the line.
+      conf.set(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname(),

Review comment:
       Based on the implementation, I don't think there was never such a use case. I guess we always except it to be contatant
   Refer:
   https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java#L66
   https://github.com/apache/hive/blob/6f9c7bc490e31ee23556a316f2ac4a886d4eff1e/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java#L1527
   https://github.com/apache/hive/blob/6f9c7bc490e31ee23556a316f2ac4a886d4eff1e/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java#L259




----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -383,7 +375,29 @@ void findUnknownPartitions(Table table, Set<Path> partPaths,
     // now check the table folder and see if we find anything
     // that isn't in the metastore
     Set<Path> allPartDirs = new HashSet<Path>();
+    Set<Path> partDirs = new HashSet<Path>();

Review comment:
       Fixed

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -383,7 +375,29 @@ void findUnknownPartitions(Table table, Set<Path> partPaths,
     // now check the table folder and see if we find anything
     // that isn't in the metastore
     Set<Path> allPartDirs = new HashSet<Path>();
+    Set<Path> partDirs = new HashSet<Path>();
+    List<FieldSchema> partColumns = table.getPartitionKeys();
     checkPartitionDirs(tablePath, allPartDirs, Collections.unmodifiableList(getPartColNames(table)));
+
+    if (filterExp != null) {
+      PartitionExpressionProxy expressionProxy = createExpressionProxy(conf);
+      List<String> paritions = new ArrayList<>();
+      for (Path path : allPartDirs) {
+        // remove the table's path from the partition path
+        // eg: <tablePath>/p1=1/p2=2/p3=3 ---> p1=1/p2=2/p3=3
+        paritions.add(path.toString().substring(tablePath.toString().length() + 1));
+      }
+      // Remove all partition paths which does not matches the filter expression.
+      expressionProxy.filterPartitionsByExpr(partColumns, filterExp,
+          conf.get(MetastoreConf.ConfVars.DEFAULTPARTITIONNAME.getVarname()), paritions);
+
+      // now the partition list will contain all the paths that matches the filter expression.
+      // add them back to partDirs.
+      for (String path : paritions) {
+        partDirs.add(new Path(tablePath.toString() + "/" + path));

Review comment:
       Fixed!




----------------------------------------------------------------
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] shameersss1 edited a comment on pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

Posted by GitBox <gi...@apache.org>.
shameersss1 edited a comment on pull request #1105:
URL: https://github.com/apache/hive/pull/1105#issuecomment-656508226


   @kgyrtkirk Is it possible trigger the pre-commit tests manually? Or Does it require a dummy commit to get it triggered? 


----------------------------------------------------------------
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 #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java
##########
@@ -63,13 +67,24 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
     }
 
     Table table = getTable(tableName);
-    List<Map<String, String>> specs = getPartitionSpecs(table, root);
+    Map<Integer, List<ExprNodeGenericFuncDesc>> partitionSpecs = getFullPartitionSpecs(root, table, conf, false);
+    byte[] filterExp = null;
+    if (partitionSpecs != null & !partitionSpecs.isEmpty()) {
+      // explicitly set expression proxy class to PartitionExpressionForMetastore since we intend to use the
+      // filterPartitionsByExpr of PartitionExpressionForMetastore for partition pruning down the line.
+      conf.set(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname(),

Review comment:
       I think it would be great to throw an exception here; I think you should throw the type `SemanticException`
   Throwing exceptions from in the `Analyzer` classes works nicely! :)




----------------------------------------------------------------
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] shameersss1 commented on pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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


   **FYI**: @kgyrtkirk Test failures seems unrelated and passed in local run.


----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java
##########
@@ -1348,6 +1348,17 @@ public static Path getPath(Table table) {
     }
   }
 
+  public static void getPartitionListByFilterExp(IMetaStoreClient msc, Table table, byte[] filterExp,
+                                                 String defaultPartName, List<Partition> results)
+      throws MetastoreException {
+    try {
+      msc.listPartitionsByExpr(table.getCatName(), table.getDbName(), table.getTableName(), filterExp,

Review comment:
       Yes, I think we also pass byte array




----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java
##########
@@ -63,13 +67,24 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
     }
 
     Table table = getTable(tableName);
-    List<Map<String, String>> specs = getPartitionSpecs(table, root);
+    Map<Integer, List<ExprNodeGenericFuncDesc>> partitionSpecs = getFullPartitionSpecs(root, table, conf, false);
+    byte[] filterExp = null;
+    if (partitionSpecs != null & !partitionSpecs.isEmpty()) {
+      // explicitly set expression proxy class to PartitionExpressionForMetastore since we intend to use the
+      // filterPartitionsByExpr of PartitionExpressionForMetastore for partition pruning down the line.
+      conf.set(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname(),

Review comment:
       Yes, It won't work with remote metastore. Currently only planning for embedded metastore, Sure, we should bail out if conditions are not met. Currently i have added the bail out code in HiveMetaStoreChecker. But i feel bail out should have been much more earlier. I Couldn't think of a better spot. Any thoughts on this?

##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -734,6 +734,21 @@ dropPartitionOperator
     EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN
     ;
 
+filterPartitionSpec
+    :
+    LPAREN filterPartitionVal (COMMA  filterPartitionVal )* RPAREN -> ^(TOK_PARTSPEC filterPartitionVal +)
+    ;
+
+filterPartitionVal
+    :
+    identifier filterPartitionOperator constant -> ^(TOK_PARTVAL identifier filterPartitionOperator constant)

Review comment:
       Based on the implementation, I don't think there was never such a use case. I guess we always except it to be contatant
   Refer:
   https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java#L66
   https://github.com/apache/hive/blob/6f9c7bc490e31ee23556a316f2ac4a886d4eff1e/ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java#L1527
   https://github.com/apache/hive/blob/6f9c7bc490e31ee23556a316f2ac4a886d4eff1e/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java#L259




----------------------------------------------------------------
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] shameersss1 commented on pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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


   @kgyrtkirk Is it possible to re-run the pre-commit tests manually? Or Does it require a dummy commit to get it triggered? 


----------------------------------------------------------------
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 #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -734,6 +734,21 @@ dropPartitionOperator
     EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN
     ;
 
+filterPartitionSpec
+    :
+    LPAREN filterPartitionVal (COMMA  filterPartitionVal )* RPAREN -> ^(TOK_PARTSPEC filterPartitionVal +)
+    ;
+
+filterPartitionVal
+    :
+    identifier filterPartitionOperator constant -> ^(TOK_PARTVAL identifier filterPartitionOperator constant)
+    ;
+
+filterPartitionOperator
+    :
+    EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN | KW_LIKE

Review comment:
       I may just blur the distinction between PARTITION/PARTITIONS :)




----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveMetaStoreChecker.java
##########
@@ -330,17 +330,6 @@ public void testPartitionsCheck() throws HiveException,
     assertEquals(partToRemove.getTable().getTableName(),
         result.getPartitionsNotOnFs().iterator().next().getTableName());
     assertEquals(Collections.<CheckResult.PartitionResult>emptySet(), result.getPartitionsNotInMs());
-
-    List<Map<String, String>> partsCopy = new ArrayList<Map<String, String>>();
-    partsCopy.add(partitions.get(1).getSpec());

Review comment:
       I think the qtests handles most of cases




----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -383,7 +375,29 @@ void findUnknownPartitions(Table table, Set<Path> partPaths,
     // now check the table folder and see if we find anything
     // that isn't in the metastore
     Set<Path> allPartDirs = new HashSet<Path>();
+    Set<Path> partDirs = new HashSet<Path>();
+    List<FieldSchema> partColumns = table.getPartitionKeys();
     checkPartitionDirs(tablePath, allPartDirs, Collections.unmodifiableList(getPartColNames(table)));
+
+    if (filterExp != null) {
+      PartitionExpressionProxy expressionProxy = createExpressionProxy(conf);
+      List<String> paritions = new ArrayList<>();
+      for (Path path : allPartDirs) {
+        // remove the table's path from the partition path
+        // eg: <tablePath>/p1=1/p2=2/p3=3 ---> p1=1/p2=2/p3=3
+        paritions.add(path.toString().substring(tablePath.toString().length() + 1));

Review comment:
       Fixed!




----------------------------------------------------------------
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] shameersss1 commented on pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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


   @kgyrtkirk Thank you for the review!. I guess i have addressed all your comments. Is there any anything that needs change or have i missed anything?


----------------------------------------------------------------
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 #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -734,6 +734,21 @@ dropPartitionOperator
     EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN
     ;
 
+filterPartitionSpec
+    :
+    LPAREN filterPartitionVal (COMMA  filterPartitionVal )* RPAREN -> ^(TOK_PARTSPEC filterPartitionVal +)
+    ;
+
+filterPartitionVal
+    :
+    identifier filterPartitionOperator constant -> ^(TOK_PARTVAL identifier filterPartitionOperator constant)

Review comment:
       old `partitionSpec` doesn't mandatorily required the constant
   ```
   identifier (EQUAL constant)? 
   ```
   
   were there any use cases of that?

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -383,7 +375,29 @@ void findUnknownPartitions(Table table, Set<Path> partPaths,
     // now check the table folder and see if we find anything
     // that isn't in the metastore
     Set<Path> allPartDirs = new HashSet<Path>();
+    Set<Path> partDirs = new HashSet<Path>();
+    List<FieldSchema> partColumns = table.getPartitionKeys();
     checkPartitionDirs(tablePath, allPartDirs, Collections.unmodifiableList(getPartColNames(table)));
+
+    if (filterExp != null) {
+      PartitionExpressionProxy expressionProxy = createExpressionProxy(conf);
+      List<String> paritions = new ArrayList<>();
+      for (Path path : allPartDirs) {
+        // remove the table's path from the partition path
+        // eg: <tablePath>/p1=1/p2=2/p3=3 ---> p1=1/p2=2/p3=3
+        paritions.add(path.toString().substring(tablePath.toString().length() + 1));
+      }
+      // Remove all partition paths which does not matches the filter expression.
+      expressionProxy.filterPartitionsByExpr(partColumns, filterExp,
+          conf.get(MetastoreConf.ConfVars.DEFAULTPARTITIONNAME.getVarname()), paritions);
+
+      // now the partition list will contain all the paths that matches the filter expression.
+      // add them back to partDirs.
+      for (String path : paritions) {
+        partDirs.add(new Path(tablePath.toString() + "/" + path));

Review comment:
       instead of concatenating with `/` use `new Path(parentPath,child)` - it's more portable

##########
File path: itests/src/test/resources/testconfiguration.properties
##########
@@ -222,6 +222,7 @@ mr.query.files=\
   mapjoin_subquery2.q,\
   mapjoin_test_outer.q,\
   masking_5.q,\
+  msck_repair_filter.q,\

Review comment:
       is there a reason that we run this test with mr?

##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
##########
@@ -1942,9 +1942,8 @@ metastoreCheck
 @after { popMsg(state); }
     : KW_MSCK (repair=KW_REPAIR)?
       (KW_TABLE tableName
-        ((add=KW_ADD | drop=KW_DROP | sync=KW_SYNC) (parts=KW_PARTITIONS))? |
-        (partitionSpec)?)
-    -> ^(TOK_MSCK $repair? tableName? $add? $drop? $sync? (partitionSpec*)?)
+        ((add=KW_ADD | drop=KW_DROP | sync=KW_SYNC) (parts=KW_PARTITIONS) (filterPartitionSpec)?)?)
+    -> ^(TOK_MSCK $repair? tableName? $add? $drop? $sync? (filterPartitionSpec)?)

Review comment:
       I know it was here before - but let's fix this up:
   
   instead of separate add/drop/sync variable ...we could have `opt=(KW_ADD|KW_DROP|KW_SYNC)` ? that will make the other end more readable as well

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java
##########
@@ -63,13 +67,24 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
     }
 
     Table table = getTable(tableName);
-    List<Map<String, String>> specs = getPartitionSpecs(table, root);
+    Map<Integer, List<ExprNodeGenericFuncDesc>> partitionSpecs = getFullPartitionSpecs(root, table, conf, false);
+    byte[] filterExp = null;
+    if (partitionSpecs != null & !partitionSpecs.isEmpty()) {
+      // explicitly set expression proxy class to PartitionExpressionForMetastore since we intend to use the
+      // filterPartitionsByExpr of PartitionExpressionForMetastore for partition pruning down the line.
+      conf.set(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname(),

Review comment:
       I don't think this will work - this is the ql module ; while `EXPRESSION_PROXY_CLASS` is a metastore conf key; in a remote metastore setup this set will probably have no effect...
   have you tried it?
   I think making a check and returning with an error that this feature is not available due to required conf change is fine

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java
##########
@@ -63,13 +67,24 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
     }
 
     Table table = getTable(tableName);
-    List<Map<String, String>> specs = getPartitionSpecs(table, root);
+    Map<Integer, List<ExprNodeGenericFuncDesc>> partitionSpecs = getFullPartitionSpecs(root, table, conf, false);
+    byte[] filterExp = null;
+    if (partitionSpecs != null & !partitionSpecs.isEmpty()) {
+      // explicitly set expression proxy class to PartitionExpressionForMetastore since we intend to use the
+      // filterPartitionsByExpr of PartitionExpressionForMetastore for partition pruning down the line.
+      conf.set(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname(),
+          PartitionExpressionForMetastore.class.getCanonicalName());
+      // fetch the first value of partitionSpecs map since it will always have one key, value pair
+      filterExp = SerializationUtilities.serializeExpressionToKryo(

Review comment:
       why this needs to be flattened into a `byte[]` ?

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/parse/BaseSemanticAnalyzer.java
##########
@@ -837,6 +844,118 @@ public static void checkColumnName(String columnName) throws SemanticException {
     return colList;
   }
 
+  /**
+   * Get the partition specs from the tree. This stores the full specification
+   * with the comparator operator into the output list.
+   *
+   * @return Map of partitions by prefix length. Most of the time prefix length will
+   *         be the same for all partition specs, so we can just OR the expressions.
+   */
+  public static Map<Integer, List<ExprNodeGenericFuncDesc>> getFullPartitionSpecs(

Review comment:
       can we find a new home for these 2 `static` methods? :)
   `ql/src/java/org/apache/hadoop/hive/ql/parse/ParseUtils.java`

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -383,7 +375,29 @@ void findUnknownPartitions(Table table, Set<Path> partPaths,
     // now check the table folder and see if we find anything
     // that isn't in the metastore
     Set<Path> allPartDirs = new HashSet<Path>();
+    Set<Path> partDirs = new HashSet<Path>();

Review comment:
       move this variable inside the if

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -240,40 +243,27 @@ void checkTable(String catName, String dbName, String tableName,
     }
 
     PartitionIterable parts;
-    boolean findUnknownPartitions = true;
 
     if (isPartitioned(table)) {
-      if (partitions == null || partitions.isEmpty()) {
+      if (filterExp != null) {
+        List<Partition> results = new ArrayList<>();
+        getPartitionListByFilterExp(getMsc(), table, filterExp,

Review comment:
       I wonder if there is a way to retain `filterExp` in a more natural way....it will be kryo-encoded almost all the time...but seems like the metastore interface method was designed to accept kryo stuff...

##########
File path: ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveMetaStoreChecker.java
##########
@@ -330,17 +330,6 @@ public void testPartitionsCheck() throws HiveException,
     assertEquals(partToRemove.getTable().getTableName(),
         result.getPartitionsNotOnFs().iterator().next().getTableName());
     assertEquals(Collections.<CheckResult.PartitionResult>emptySet(), result.getPartitionsNotInMs());
-
-    List<Map<String, String>> partsCopy = new ArrayList<Map<String, String>>();
-    partsCopy.add(partitions.get(1).getSpec());

Review comment:
       is there a successor of this test?

##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -734,6 +734,21 @@ dropPartitionOperator
     EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN
     ;
 
+filterPartitionSpec
+    :
+    LPAREN filterPartitionVal (COMMA  filterPartitionVal )* RPAREN -> ^(TOK_PARTSPEC filterPartitionVal +)
+    ;
+
+filterPartitionVal
+    :
+    identifier filterPartitionOperator constant -> ^(TOK_PARTVAL identifier filterPartitionOperator constant)
+    ;
+
+filterPartitionOperator
+    :
+    EQUAL | NOTEQUAL | LESSTHANOREQUALTO | LESSTHAN | GREATERTHANOREQUALTO | GREATERTHAN | KW_LIKE

Review comment:
       `dropPartitionSpec` seems to use almost the same construct ; I don't see any reason to duplicate it ...
   the only difference I see right now is `LIKE` - are there any other differences?
   
   I think instead of duplicate we should use the same stuff...

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreChecker.java
##########
@@ -383,7 +375,29 @@ void findUnknownPartitions(Table table, Set<Path> partPaths,
     // now check the table folder and see if we find anything
     // that isn't in the metastore
     Set<Path> allPartDirs = new HashSet<Path>();
+    Set<Path> partDirs = new HashSet<Path>();
+    List<FieldSchema> partColumns = table.getPartitionKeys();
     checkPartitionDirs(tablePath, allPartDirs, Collections.unmodifiableList(getPartColNames(table)));
+
+    if (filterExp != null) {
+      PartitionExpressionProxy expressionProxy = createExpressionProxy(conf);
+      List<String> paritions = new ArrayList<>();
+      for (Path path : allPartDirs) {
+        // remove the table's path from the partition path
+        // eg: <tablePath>/p1=1/p2=2/p3=3 ---> p1=1/p2=2/p3=3
+        paritions.add(path.toString().substring(tablePath.toString().length() + 1));

Review comment:
       I'm wondering if `tablePath` could end with a '/' or not; if it does, and `checkPartitionDirs` are removing double slashes this could eat up 1 extra char...

##########
File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreServerUtils.java
##########
@@ -1348,6 +1348,17 @@ public static Path getPath(Table table) {
     }
   }
 
+  public static void getPartitionListByFilterExp(IMetaStoreClient msc, Table table, byte[] filterExp,
+                                                 String defaultPartName, List<Partition> results)
+      throws MetastoreException {
+    try {
+      msc.listPartitionsByExpr(table.getCatName(), table.getDbName(), table.getTableName(), filterExp,

Review comment:
       this method accepts `byte[]` and if I'm not wrong this is like this since around 2013 




----------------------------------------------------------------
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] shameersss1 commented on a change in pull request #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: itests/src/test/resources/testconfiguration.properties
##########
@@ -222,6 +222,7 @@ mr.query.files=\
   mapjoin_subquery2.q,\
   mapjoin_test_outer.q,\
   masking_5.q,\
+  msck_repair_filter.q,\

Review comment:
       Not a requirement though. This was done before we moved our qtests to run on LLAP by default. It makes sense to move this to LLAP as well.
   Fixed.

##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
##########
@@ -1942,9 +1942,8 @@ metastoreCheck
 @after { popMsg(state); }
     : KW_MSCK (repair=KW_REPAIR)?
       (KW_TABLE tableName
-        ((add=KW_ADD | drop=KW_DROP | sync=KW_SYNC) (parts=KW_PARTITIONS))? |
-        (partitionSpec)?)
-    -> ^(TOK_MSCK $repair? tableName? $add? $drop? $sync? (partitionSpec*)?)
+        ((add=KW_ADD | drop=KW_DROP | sync=KW_SYNC) (parts=KW_PARTITIONS) (filterPartitionSpec)?)?)
+    -> ^(TOK_MSCK $repair? tableName? $add? $drop? $sync? (filterPartitionSpec)?)

Review comment:
       Yes It makes sense!. Fixed.




----------------------------------------------------------------
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 #1105: HIVE-22957: Support Partition Filtering In MSCK REPAIR TABLE Command

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



##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/HiveParser.g
##########
@@ -1942,8 +1942,8 @@ metastoreCheck
 @after { popMsg(state); }
     : KW_MSCK (repair=KW_REPAIR)?
       (KW_TABLE tableName
-        (opt=(KW_ADD|KW_DROP|KW_SYNC) (parts=KW_PARTITIONS) (filterPartitionSpec)?)?)
-    -> ^(TOK_MSCK $repair? tableName? $opt? (filterPartitionSpec)?)
+        (opt=(KW_ADD|KW_DROP|KW_SYNC) (parts=KW_PARTITIONS)? (dropPartitionSpec)?)?)

Review comment:
       I think we are fighting with the complexity of the existing complexity :)
   
   right now this will mean that we may write `TABLE t PARTITION PARTITION ...`  :D
   
   do one of the following:
   * either push out the `KW_PARTITION` keyword from `dropPartitionSpec` to every site it's being used
   * or...remove the `(parts=KW_PARTITIONS)?` from here and change the `dropPartitionSpec` to accept it optionally by using: `(KW_PARTITION | KW_PARTITIONS)?` 
   
   I think we should also clean up a bit:
   * rename the `dropPartitionSpec` to something which doesn't have drop in its name like `partitionSelectorSpec`
   

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/ddl/misc/msck/MsckAnalyzer.java
##########
@@ -71,10 +71,15 @@ public void analyzeInternal(ASTNode root) throws SemanticException {
     Map<Integer, List<ExprNodeGenericFuncDesc>> partitionSpecs = ParseUtils.getFullPartitionSpecs(root, table, conf, false);
     byte[] filterExp = null;
     if (partitionSpecs != null & !partitionSpecs.isEmpty()) {
-      // explicitly set expression proxy class to PartitionExpressionForMetastore since we intend to use the
+      // expression proxy class needs to be PartitionExpressionForMetastore since we intend to use the
       // filterPartitionsByExpr of PartitionExpressionForMetastore for partition pruning down the line.
-      conf.set(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname(),
-          PartitionExpressionForMetastore.class.getCanonicalName());
+      // Bail out early if expressionProxyClass is not configured properly.
+      String expressionProxyClass = conf.get(MetastoreConf.ConfVars.EXPRESSION_PROXY_CLASS.getVarname());
+      if (expressionProxyClass == null || expressionProxyClass.isEmpty() ||
+          !expressionProxyClass.equals(PartitionExpressionForMetastore.class.getCanonicalName())) {

Review comment:
       you could avoid the null/empty check by using: `!PartitionExpressionForMetastore.class.getCanonicalName()).equals(expressionProxyClass)`

##########
File path: parser/src/java/org/apache/hadoop/hive/ql/parse/IdentifiersParser.g
##########
@@ -720,7 +720,7 @@ partitionVal
 
 dropPartitionSpec
     :
-    KW_PARTITION
+    KW_PARTITION | KW_PARTITIONS

Review comment:
       I think this should be `(KW_PARTITION|KW_PARTITIONS)`  ; because in it's current form it will
   * accept `PARTITION`
   * and `PARTITIONS  (...)`
   * but not  `PARTITION (...)`




----------------------------------------------------------------
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] shameersss1 commented on pull request #1105: HIVE-22957: Add Option For Predicate Filtering In MSCK REPAIR TABLE Command

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


   @kgyrtkirk @jcamachor @prasanthj Could you please review?


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