@@ -43,15 +43,30 @@ pub use datafusion_expr::planner::ContextProvider;
4343/// SQL parser options
4444#[ derive( Debug , Clone , Copy ) ]
4545pub struct ParserOptions {
46+ /// Whether to parse float as decimal.
4647 pub parse_float_as_decimal : bool ,
48+ /// Whether to normalize identifiers.
4749 pub enable_ident_normalization : bool ,
50+ /// Whether to support varchar with length.
4851 pub support_varchar_with_length : bool ,
52+ /// Whether to normalize options value.
4953 pub enable_options_value_normalization : bool ,
54+ /// Whether to collect spans
5055 pub collect_spans : bool ,
5156}
5257
53- impl Default for ParserOptions {
54- fn default ( ) -> Self {
58+ impl ParserOptions {
59+ /// Creates a new `ParserOptions` instance with default values.
60+ ///
61+ /// # Examples
62+ ///
63+ /// ```
64+ /// use datafusion_sql::planner::ParserOptions;
65+ /// let opts = ParserOptions::new();
66+ /// assert_eq!(opts.parse_float_as_decimal, false);
67+ /// assert_eq!(opts.enable_ident_normalization, true);
68+ /// ```
69+ pub fn new ( ) -> Self {
5570 Self {
5671 parse_float_as_decimal : false ,
5772 enable_ident_normalization : true ,
@@ -60,6 +75,58 @@ impl Default for ParserOptions {
6075 collect_spans : false ,
6176 }
6277 }
78+
79+ /// Sets the `parse_float_as_decimal` option.
80+ ///
81+ /// # Examples
82+ ///
83+ /// ```
84+ /// use datafusion_sql::planner::ParserOptions;
85+ /// let opts = ParserOptions::new().with_parse_float_as_decimal(true);
86+ /// assert_eq!(opts.parse_float_as_decimal, true);
87+ /// ```
88+ pub fn with_parse_float_as_decimal ( mut self , value : bool ) -> Self {
89+ self . parse_float_as_decimal = value;
90+ self
91+ }
92+
93+ /// Sets the `enable_ident_normalization` option.
94+ ///
95+ /// # Examples
96+ ///
97+ /// ```
98+ /// use datafusion_sql::planner::ParserOptions;
99+ /// let opts = ParserOptions::new().with_enable_ident_normalization(false);
100+ /// assert_eq!(opts.enable_ident_normalization, false);
101+ /// ```
102+ pub fn with_enable_ident_normalization ( mut self , value : bool ) -> Self {
103+ self . enable_ident_normalization = value;
104+ self
105+ }
106+
107+ /// Sets the `support_varchar_with_length` option.
108+ pub fn with_support_varchar_with_length ( mut self , value : bool ) -> Self {
109+ self . support_varchar_with_length = value;
110+ self
111+ }
112+
113+ /// Sets the `enable_options_value_normalization` option.
114+ pub fn with_enable_options_value_normalization ( mut self , value : bool ) -> Self {
115+ self . enable_options_value_normalization = value;
116+ self
117+ }
118+
119+ /// Sets the `collect_spans` option.
120+ pub fn with_collect_spans ( mut self , value : bool ) -> Self {
121+ self . collect_spans = value;
122+ self
123+ }
124+ }
125+
126+ impl Default for ParserOptions {
127+ fn default ( ) -> Self {
128+ Self :: new ( )
129+ }
63130}
64131
65132/// Ident Normalizer
0 commit comments