danny0405 commented on a change in pull request #1485: [CALCITE-2792]
Stackoverflow while evaluating filter with large number of OR conditions
URL: https://github.com/apache/calcite/pull/1485#discussion_r333395529
##########
File path:
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java
##########
@@ -677,8 +677,13 @@ public SqlNode toSql(RexProgram program, RexNode rex) {
}
if (op instanceof SqlBinaryOperator && nodeList.size() > 2) {
// In RexNode trees, OR and AND have any number of children;
- // SqlCall requires exactly 2. So, convert to a left-deep binary
tree.
- return createLeftCall(op, nodeList);
+ // SqlCall requires exactly 2. So, convert to a balanced binary
+ // tree for OR/AND, left-deep binary tree for others.
+ if (op.kind == SqlKind.OR || op.kind == SqlKind.AND) {
+ return createBalancedCall(op, nodeList, 0, nodeList.size());
Review comment:
Can we set a threshold for balanced call ? The left call looks more
intuitive in the plan although it may causes StackOverflow.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services