soumyakanti3578 commented on PR #6318:
URL: https://github.com/apache/hive/pull/6318#issuecomment-3917488268
@kasakrisz
From the failed tests, it looks like `CAST` would not pass the `Filter`
litmus test, as seen in the test failure:
`materialized_view_rewrite_in_between.q`.
How about just creating a new `RexCall` with the type of the `search`, since
we want the new conjunction expression to have the same type as the `SEARCH`? I
tried a few failing tests with this change and they all passed.
```
---
a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/SearchTransformer.java
+++
b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/SearchTransformer.java
@@ -59,22 +59,24 @@ public class SearchTransformer<C extends Comparable<C>> {
private final RexNode ref;
private final Sarg<C> sarg;
private final RexUnknownAs unknownContext;
- protected final RelDataType type;
+ protected final RelDataType operandType;
+ private final RelDataType expressionType;
public SearchTransformer(RexBuilder rexBuilder, RexCall search, final
RexUnknownAs unknownContext) {
this.rexBuilder = rexBuilder;
ref = search.getOperands().get(0);
RexLiteral literal = (RexLiteral) search.operands.get(1);
sarg = Objects.requireNonNull(literal.getValueAs(Sarg.class), "Sarg");
- type = literal.getType();
+ operandType = literal.getType();
this.unknownContext = unknownContext;
+ this.expressionType = search.getType();
}
public RexNode transform() {
PerfLogger perfLogger = SessionState.getPerfLogger();
perfLogger.perfLogBegin(this.getClass().getName(),
PerfLogger.SEARCH_TRANSFORMER);
- RangeConverter<C> consumer = new RangeConverter<>(rexBuilder, type,
ref);
+ RangeConverter<C> consumer = new RangeConverter<>(rexBuilder,
operandType, ref);
RangeSets.forEach(sarg.rangeSet, consumer);
List<RexNode> orList = new ArrayList<>();
@@ -101,6 +103,11 @@ public RexNode transform() {
x = RexUtil.composeConjunction(rexBuilder, Arrays.asList(notNull, x));
}
perfLogger.perfLogEnd(this.getClass().getName(),
PerfLogger.SEARCH_TRANSFORMER);
+
+ if (!expressionType.equals(x.getType())) {
+ x = rexBuilder.makeCall(expressionType, ((RexCall) x).getOperator(),
((RexCall) x).getOperands());
+ }
+
return x;
}
```
--
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]