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

 ##########
 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:
   substring match is error prone. Can we split/join and do exact match? 
   Example, year=2001 and next_year=2001 will both match for year=2001 search. 
Hence my concern.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to