[ 
https://issues.apache.org/jira/browse/HIVE-27264?focusedWorklogId=857263&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-857263
 ]

ASF GitHub Bot logged work on HIVE-27264:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 16/Apr/23 20:38
            Start Date: 16/Apr/23 20:38
    Worklog Time Spent: 10m 
      Work Description: amansinha100 commented on code in PR #4237:
URL: https://github.com/apache/hive/pull/4237#discussion_r1168016810


##########
ql/src/test/queries/clientpositive/pointlookup6.q:
##########
@@ -0,0 +1,17 @@
+create table r_table (

Review Comment:
   Should these tests set the hive.optimize.point.lookup and 
hive.optimize.point.lookup.min explicitly since the default values could 
change. 



##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HivePointLookupOptimizerRule.java:
##########
@@ -669,6 +670,22 @@ private static RexNode handleAND(RexBuilder rexBuilder, 
RexCall call) {
       return RexUtil.composeConjunction(rexBuilder, newOperands, false);
     }
 
+    private static void retainAll(Collection<RexNode> elementsToRetain, 
Collection<RexNode> collection) {
+      collection.removeIf(rexNode -> elementsToRetain.stream().noneMatch(
+              rexNodeToRetain -> equalsWithSimilarType(rexNode, 
rexNodeToRetain)));
+    }
+
+    private static boolean equalsWithSimilarType(RexNode rexNode1, RexNode 
rexNode2) {
+      if (!(rexNode1 instanceof RexLiteral) || !(rexNode2 instanceof 
RexLiteral)) {
+        return rexNode1.equals(rexNode2);
+      }
+
+      RexLiteral rexLiteral1 = (RexLiteral) rexNode1;
+      RexLiteral rexLiteral2 = (RexLiteral) rexNode2;
+      return rexLiteral1.getValue().compareTo(rexLiteral2.getValue()) == 0 &&
+              
rexLiteral1.getType().getSqlTypeName().equals(rexLiteral2.getType().getSqlTypeName());

Review Comment:
   The SqlTypeName is being compared twice. Previously, it was compared by the 
shareSameType() function on lines 623, 653.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 857263)
    Time Spent: 0.5h  (was: 20m)

> Literals in conjunction of two in expression are considered not equals if 
> type precision is different
> -----------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-27264
>                 URL: https://issues.apache.org/jira/browse/HIVE-27264
>             Project: Hive
>          Issue Type: Bug
>          Components: CBO
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> {code}
> create table r_table (
>   string_col varchar(30)
> );
> create table l_table (
>   string_col varchar(14)
> );
> insert into r_table VALUES ('AAA111');
> insert into l_table VALUES ('AAA111');
> SELECT l_table.string_col from l_table, r_table
> WHERE r_table.string_col = l_table.string_col AND l_table.string_col IN 
> ('AAA111', 'BBB222') AND r_table.string_col IN ('AAA111', 'BBB222');
> {code}
> Should give one row
> {code}
> AAA111
> {code}
> but it returns empty rs
> Workaround
> {code}
> set hive.optimize.point.lookup=false;
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to