libenchao commented on code in PR #2686:
URL: https://github.com/apache/calcite/pull/2686#discussion_r1012476387
##########
core/src/main/java/org/apache/calcite/rel/rules/ProjectJoinTransposeRule.java:
##########
@@ -157,7 +159,24 @@ public ProjectJoinTransposeRule(
@Value.Immutable(singleton = false)
public interface Config extends RelRule.Config {
Config DEFAULT = ImmutableProjectJoinTransposeRule.Config.builder()
- .withPreserveExprCondition(expr -> !(expr instanceof RexOver))
+ .withPreserveExprCondition(expr -> {
+ // Do not push down over's expression by default
+ if (expr instanceof RexOver) {
+ return false;
+ }
+ final RelDataType relType = expr.getType();
Review Comment:
Sorry that I was not clear enough on this. I mean:
```java
if (expr instanceof RexOver) {
return false;
}
if (SqlKind.CAST == expr.getKind()) {
final RelDataType relType = expr.getType();
final RexCall castCall = (RexCall) expr;
final RelDataType operand0Type =
castCall.getOperands().get(0).getType();
if (relType.getSqlTypeName() == operand0Type.getSqlTypeName()
&& operand0Type.isNullable() && !relType.isNullable()) {
// Do not push down not nullable cast's expression with the
same type by default
// eg: CAST($1):VARCHAR(10) NOT NULL, and type of $1 is
nullable VARCHAR(10)
return false;
}
}
```
--
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]