soumyakanti3578 commented on code in PR #5196:
URL: https://github.com/apache/hive/pull/5196#discussion_r1940313899


##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/jdbc/JDBCExpandExpressionsRule.java:
##########
@@ -182,12 +191,75 @@ public RexNode visitCall(RexCall inputCall) {
         switch (call.getKind()) {
           case IN:
             return transformIntoOrAndClause(rexBuilder, call);
+          case SEARCH:
+            return expandSearchAndRemoveRowOperator(rexBuilder, call);
           default:
             break;
         }
       }
       return RexUtil.isFlat(node) ? node : RexUtil.flatten(rexBuilder, node);
     }
+    
+    private RexNode expandSearchAndRemoveRowOperator(RexBuilder rexBuilder, 
RexCall expression) {
+      RexLiteral literal = (RexLiteral) expression.getOperands().get(1);
+      Sarg<?> sarg = Objects.requireNonNull(literal.getValueAs(Sarg.class), 
"Sarg");
+
+      if (sarg.isPoints()) {
+        // if it is a row operator, we'll have 
+        // SEARCH(ROW($1, $2), Sarg[[1, 2], [3, 4]]

Review Comment:
   Just for clarification, `ROW` appears in calcite 1.25 too. Here's the same 
partial predicate that 1.25 generates:
   ```
   IN(ROW($1, $2), ROW(10:BIGINT, 1.515E1:DOUBLE), ROW(20:BIGINT, 
2.525E1:DOUBLE))
   ```
   and this is removed in `JDBCExpandExpressionsRule` here:
   
https://github.com/apache/hive/blob/84cdf6003678ed673d59d223ef7f4dac1aa6fdc0/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/jdbc/JDBCExpandExpressionsRule.java#L192
   
   with the help of `RexNodeConverter.transformInToOrOperands(List<RexNode> 
operands, RexBuilder rexBuilder)`. 
   
   So, I have tried to convert `Sargs` to equivalent `ROW` operands before 
passing it through the same method above.
   
   Ideally, it would be better to do this in Calcite. At the least, Calcite 
could return `SEARCH(ROW($1, $2), Sarg[ROW(a, b), ROW(c, d)])`, so that it's 
easier to extract the ROWs from the Sarg.
   



-- 
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-unsubscr...@hive.apache.org

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


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

Reply via email to