zabetak commented on code in PR #6895:
URL: https://github.com/apache/hive/pull/6895#discussion_r4705717391
##########
ql/src/java/org/apache/hadoop/hive/ql/optimizer/SemiJoinReductionMerge.java:
##########
@@ -153,7 +153,8 @@ public ParseContext transform(ParseContext parseContext)
throws SemanticExceptio
}
}
// Update tableScan with the new semi-join predicate
-
sjTargetTable.getConf().setFilterExpr(and(sjTargetTable.getConf().getFilterExpr(),
sjPredicate));
+ sjTargetTable.getConf()
+ .setFilterExpr((ExprNodeGenericFuncDesc)
and(sjTargetTable.getConf().getFilterExpr(), sjPredicate));
Review Comment:
Requiring casts increases the risk of `ClassCastException` so the new code
does not seem better.
##########
ql/src/java/org/apache/hadoop/hive/ql/io/HiveInputFormat.java:
##########
@@ -960,7 +961,10 @@ public static void pushFiltersAndAsOf(JobConf jobConf,
TableScanOperator tableSc
ExprNodeGenericFuncDesc pruningExpr =
SerializationUtilities.deserializeExpression(pruningFilter);
if (filterExpr != null) {
// Combine the 2 filters with AND
- filterExpr = ExprNodeDescUtils.and(filterExpr, pruningExpr);
+ ExprNodeDesc combinedExpr = ExprNodeDescUtils.and(filterExpr,
pruningExpr);
+ if (combinedExpr instanceof ExprNodeGenericFuncDesc combinedFuncExpr) {
+ filterExpr = combinedFuncExpr;
+ }
Review Comment:
If the instanceof fails then we are going to ignore the `pruningExpr`. Not
sure if its possible now but it may silently fail if something changes in the
future.
##########
ql/src/test/queries/clientpositive/operands_deduplication.q:
##########
@@ -0,0 +1,7 @@
+create table mytable(id int, name string);
+
+explain cbo select t1.id, t2.name, (case when (t1.id = 1 and t2.id = 1) then
'One' else null end) mycase
+from mytable t1 join mytable t2 on t1.name = t2.name where t1.id =1 and t2.id
= 1;
+
+explain cbo select t1.id, t2.name, (case when (t1.id = 1 or t2.id = 1) then
'One' else null end) mycase
+from mytable t1 join mytable t2 on t1.name = t2.name where t1.id = 1 and t2.id
= 1;
Review Comment:
Explain query is duplicated
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]