Closed as not planned
Description
Describe the bug
Consider the contrived query generated with this:
print('SELECT * FROM VALUES(1) WHERE ' + ' OR '.join(['column1 = ' + str(i) for i in range(10000)]))
It looks like this:
SELECT * FROM VALUES(1) WHERE column1 = 0 OR column1 = 1 OR column1 = 2 ...
Such a query overflows the stack.
To Reproduce
python3 -c "print('SELECT * FROM VALUES(1) WHERE ' + ' OR '.join(['column1 = ' + str(i) for i in range(10000)]))" > /tmp/query.sql
datafusion-cli -f /tmp/query.sql
# output below
DataFusion CLI v39.0.0
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)
Expected behavior
I expected that the query ran successfully, or provided an error.
Additional context
LLDB shows that the culprit might be that map_children
of Expr
is recursive.
lldb datafusion-cli
settings set target.run-args -f /tmp/query.sql
run
bt
# shows deep stack trace like this
* frame #0: 0x0000555557159771 datafusion-cli`datafusion_expr::tree_node::_$LT$impl$u20$datafusion_common..tree_node..TreeNode$u20$for$u20$datafusion_expr..expr..Expr$GT$::map_children::hc2fc8c2c6eec78b5 + 17
frame #1: 0x00005555572f4b46 datafusion-cli`datafusion_expr::tree_node::transform_box::h4a3722c597863a90 + 70
frame #2: 0x0000555557159acc datafusion-cli`datafusion_expr::tree_node::_$LT$impl$u20$datafusion_common..tree_node..TreeNode$u20$for$u20$datafusion_expr..expr..Expr$GT$::map_children::hc2fc8c2c6eec78b5 + 876
frame #3: 0x00005555572f4b46 datafusion-cli`datafusion_expr::tree_node::transform_box::h4a3722c597863a90 + 70
frame #4: 0x0000555557159acc datafusion-cli`datafusion_expr::tree_node::_$LT$impl$u20$datafusion_common..tree_node..TreeNode$u20$for$u20$datafusion_expr..expr..Expr$GT$::map_children::hc2fc8c2c6eec78b5 + 876
frame #5: 0x00005555572f4b46 datafusion-cli`datafusion_expr::tree_node::transform_box::h4a3722c597863a90 + 70
frame #6: 0x0000555557159acc datafusion-cli`datafusion_expr::tree_node::_$LT$impl$u20$datafusion_common..tree_node..TreeNode$u20$for$u20$datafusion_expr..expr..Expr$GT$::map_children::hc2fc8c2c6eec78b5 + 876
frame #7: 0x00005555572f4b46 datafusion-cli`datafusion_expr::tree_node::transform_box::h4a3722c597863a90 + 70
frame #8: 0x0000555557159acc datafusion-cli`datafusion_expr::tree_node::_$LT$impl$u20$datafusion_common..tree_node..TreeNode$u20$for$u20$datafusion_expr..expr..Expr$GT$::map_children::hc2fc8c2c6eec78b5 + 876