@@ -43,15 +43,30 @@ pub use datafusion_expr::planner::ContextProvider;
43
43
/// SQL parser options
44
44
#[ derive( Debug , Clone , Copy ) ]
45
45
pub struct ParserOptions {
46
+ /// Whether to parse float as decimal.
46
47
pub parse_float_as_decimal : bool ,
48
+ /// Whether to normalize identifiers.
47
49
pub enable_ident_normalization : bool ,
50
+ /// Whether to support varchar with length.
48
51
pub support_varchar_with_length : bool ,
52
+ /// Whether to normalize options value.
49
53
pub enable_options_value_normalization : bool ,
54
+ /// Whether to collect spans
50
55
pub collect_spans : bool ,
51
56
}
52
57
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 {
55
70
Self {
56
71
parse_float_as_decimal : false ,
57
72
enable_ident_normalization : true ,
@@ -60,6 +75,58 @@ impl Default for ParserOptions {
60
75
collect_spans : false ,
61
76
}
62
77
}
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
+ }
63
130
}
64
131
65
132
/// Ident Normalizer
0 commit comments