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/04/06 16:48:21 UTC

[GitHub] [hive] prasanthj commented on a change in pull request #968: Hive23111

prasanthj commented on a change in pull request #968: Hive23111
URL: https://github.com/apache/hive/pull/968#discussion_r404239072
 
 

 ##########
 File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MsckPartitionExpressionProxy.java
 ##########
 @@ -44,6 +53,46 @@ public String convertExprToFilter(final byte[] exprBytes, final String defaultPa
   @Override
   public boolean filterPartitionsByExpr(List<FieldSchema> partColumns, byte[] expr, String
     defaultPartitionName, List<String> partitionNames) throws MetaException {
+    String partExpr = new String(expr, StandardCharsets.UTF_8);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Partition expr: {}", expr);
+    }
+    //This is to find in partitionNames all that match expr
+    //reverse of the Msck.makePartExpr
+    Set<String> partValueSet = new HashSet<>();
+    String[] parts = partExpr.split(" AND ");
+    for ( String part : parts){
+      String[] colAndValue = part.split("=");
+      String key = FileUtils.unescapePathName(colAndValue[0]);
+      //take the value inside without the single quote marks '2018-10-30' becomes 2018-10-31
+      String value = FileUtils.unescapePathName(colAndValue[1].substring(1, colAndValue[1].length()-1));
+      partValueSet.add(key+"="+value);
+    }
+
+    List<String> partNamesSeq =  new ArrayList<>();
+    for (String partition : partitionNames){
+      boolean isMatch = true;
+      for ( String col : partValueSet){
+        //list of partitions [year=2001/month=1, year=2002/month=2, year=2001/month=3]
+        //Given expr: e.g. year='2001' AND month='1'. Only when all the expressions in the expr can be found,
 
 Review comment:
   Looks like we are doing exact match here?
   If so, should we just do contains check in partValueSet?

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


With regards,
Apache Git Services

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