datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

`datafusion-cli` ignores `datafusion.sql_parser.recursion_limit`

Open edubraqd opened this issue 3 months ago • 2 comments

Describe the bug

exec_and_print in datafusion-cli/src/exec.rs parses statements with DFParser::parse_sql_with_dialect, which always uses the parser's built-in recursion limit (50). The session option datafusion.sql_parser.recursion_limit is read by SessionState::sql_to_statement (via DFParserBuilder::with_recursion_limit) but never by the CLI, so changing it has no effect there.

To Reproduce

> SET datafusion.sql_parser.recursion_limit = 100;
> SELECT abs(abs(abs( ... 60 nested calls ... )));
SQL error: RecursionLimitExceeded (current limit: 50)

The same statement succeeds through SessionContext::sql with that option set.

Expected behavior

The CLI parses with the session's recursion_limit, like SessionState::sql_to_statement.

Additional context

Noticed while testing deeply nested expressions in datafusion-cli.

edubraqd avatar Sep 03 '26 04:09 edubraqd

take

KassaSana avatar Sep 27 '26 14:09 KassaSana

I reproduced this on current main. The configured recursion limit is ignored in -c, -f, env-based config, and the interactive shell.

The fix appears to need both:

  • exec_and_print in exec.rs
  • CliHelper::validate_input in helper.rs

The earlier attempt in #24914 handled the execution path but not the REPL validation path.

My plan is to use DFParserBuilder::with_recursion_limit for execution and keep the recursion limit in CliHelper synchronized similarly to the existing dialect handling, with tests for both paths.

Would you prefer a narrow set_recursion_limit method, or a broader parser-options setter?

KassaSana avatar Sep 27 '26 14:09 KassaSana