@@ -70,10 +70,11 @@ impl CliHelper {
7070 }
7171 }
7272
73- /// Sets the recursion limit used when validating input, see
74- /// `datafusion.sql_parser.recursion_limit`.
75- pub fn set_recursion_limit ( & mut self , recursion_limit : usize ) {
76- self . recursion_limit = recursion_limit;
73+ /// Sets the parser options (dialect and recursion limit) used when
74+ /// validating input, see `datafusion.sql_parser.*`.
75+ pub fn set_parser_options ( & mut self , options : & SqlParserOptions ) {
76+ self . set_dialect ( & options. dialect ) ;
77+ self . recursion_limit = options. recursion_limit . get ( ) ;
7778 }
7879
7980 /// Re-enable the default hint for the next prompt.
@@ -227,6 +228,8 @@ mod tests {
227228
228229 use super :: * ;
229230
231+ use datafusion_common:: config:: ConfigNonZeroUsize ;
232+
230233 fn readline_direct (
231234 mut reader : impl BufRead ,
232235 validator : & CliHelper ,
@@ -337,18 +340,22 @@ mod tests {
337340 let nested = |depth : usize | {
338341 format ! ( "select {}1{};" , "abs(" . repeat( depth) , ")" . repeat( depth) )
339342 } ;
343+ let with_limit = |limit : usize | SqlParserOptions {
344+ recursion_limit : ConfigNonZeroUsize :: try_new ( limit) . unwrap ( ) ,
345+ ..Default :: default ( )
346+ } ;
340347
341348 // exceeds the default recursion limit
342349 let result = readline_direct ( Cursor :: new ( nested ( 60 ) ) , & validator) ?;
343350 assert ! (
344351 matches!( result, ValidationResult :: Invalid ( Some ( e) ) if e. contains( "RecursionLimitExceeded" ) )
345352 ) ;
346353
347- validator. set_recursion_limit ( 100 ) ;
354+ validator. set_parser_options ( & with_limit ( 100 ) ) ;
348355 let result = readline_direct ( Cursor :: new ( nested ( 60 ) ) , & validator) ?;
349356 assert ! ( matches!( result, ValidationResult :: Valid ( None ) ) ) ;
350357
351- validator. set_recursion_limit ( 5 ) ;
358+ validator. set_parser_options ( & with_limit ( 5 ) ) ;
352359 let result = readline_direct ( Cursor :: new ( nested ( 10 ) ) , & validator) ?;
353360 assert ! (
354361 matches!( result, ValidationResult :: Invalid ( Some ( e) ) if e. contains( "RecursionLimitExceeded" ) )
0 commit comments