@@ -46,11 +46,18 @@ pub trait Dialect: Send + Sync {
46
46
IntervalStyle :: PostgresVerbose
47
47
}
48
48
49
+ // Does the dialect use DOUBLE PRECISION to represent Float64 rather than DOUBLE?
50
+ // E.g. Postgres uses DOUBLE PRECISION instead of DOUBLE
51
+ fn float64_ast_dtype ( & self ) -> sqlparser:: ast:: DataType {
52
+ sqlparser:: ast:: DataType :: Double
53
+ }
54
+
49
55
// The SQL type to use for Arrow Utf8 unparsing
50
56
// Most dialects use VARCHAR, but some, like MySQL, require CHAR
51
57
fn utf8_cast_dtype ( & self ) -> ast:: DataType {
52
58
ast:: DataType :: Varchar ( None )
53
59
}
60
+
54
61
// The SQL type to use for Arrow LargeUtf8 unparsing
55
62
// Most dialects use TEXT, but some, like MySQL, require CHAR
56
63
fn large_utf8_cast_dtype ( & self ) -> ast:: DataType {
@@ -98,6 +105,10 @@ impl Dialect for PostgreSqlDialect {
98
105
fn interval_style ( & self ) -> IntervalStyle {
99
106
IntervalStyle :: PostgresVerbose
100
107
}
108
+
109
+ fn float64_ast_dtype ( & self ) -> sqlparser:: ast:: DataType {
110
+ sqlparser:: ast:: DataType :: DoublePrecision
111
+ }
101
112
}
102
113
103
114
pub struct MySqlDialect { }
@@ -137,6 +148,7 @@ pub struct CustomDialect {
137
148
supports_nulls_first_in_sort : bool ,
138
149
use_timestamp_for_date64 : bool ,
139
150
interval_style : IntervalStyle ,
151
+ float64_ast_dtype : sqlparser:: ast:: DataType ,
140
152
utf8_cast_dtype : ast:: DataType ,
141
153
large_utf8_cast_dtype : ast:: DataType ,
142
154
}
@@ -148,6 +160,7 @@ impl Default for CustomDialect {
148
160
supports_nulls_first_in_sort : true ,
149
161
use_timestamp_for_date64 : false ,
150
162
interval_style : IntervalStyle :: SQLStandard ,
163
+ float64_ast_dtype : sqlparser:: ast:: DataType :: Double ,
151
164
utf8_cast_dtype : ast:: DataType :: Varchar ( None ) ,
152
165
large_utf8_cast_dtype : ast:: DataType :: Text ,
153
166
}
@@ -182,6 +195,10 @@ impl Dialect for CustomDialect {
182
195
self . interval_style
183
196
}
184
197
198
+ fn float64_ast_dtype ( & self ) -> sqlparser:: ast:: DataType {
199
+ self . float64_ast_dtype . clone ( )
200
+ }
201
+
185
202
fn utf8_cast_dtype ( & self ) -> ast:: DataType {
186
203
self . utf8_cast_dtype . clone ( )
187
204
}
@@ -210,6 +227,7 @@ pub struct CustomDialectBuilder {
210
227
supports_nulls_first_in_sort : bool ,
211
228
use_timestamp_for_date64 : bool ,
212
229
interval_style : IntervalStyle ,
230
+ float64_ast_dtype : sqlparser:: ast:: DataType ,
213
231
utf8_cast_dtype : ast:: DataType ,
214
232
large_utf8_cast_dtype : ast:: DataType ,
215
233
}
@@ -227,6 +245,7 @@ impl CustomDialectBuilder {
227
245
supports_nulls_first_in_sort : true ,
228
246
use_timestamp_for_date64 : false ,
229
247
interval_style : IntervalStyle :: PostgresVerbose ,
248
+ float64_ast_dtype : sqlparser:: ast:: DataType :: Double ,
230
249
utf8_cast_dtype : ast:: DataType :: Varchar ( None ) ,
231
250
large_utf8_cast_dtype : ast:: DataType :: Text ,
232
251
}
@@ -238,6 +257,7 @@ impl CustomDialectBuilder {
238
257
supports_nulls_first_in_sort : self . supports_nulls_first_in_sort ,
239
258
use_timestamp_for_date64 : self . use_timestamp_for_date64 ,
240
259
interval_style : self . interval_style ,
260
+ float64_ast_dtype : self . float64_ast_dtype ,
241
261
utf8_cast_dtype : self . utf8_cast_dtype ,
242
262
large_utf8_cast_dtype : self . large_utf8_cast_dtype ,
243
263
}
@@ -273,6 +293,14 @@ impl CustomDialectBuilder {
273
293
self
274
294
}
275
295
296
+ pub fn with_float64_ast_dtype (
297
+ mut self ,
298
+ float64_ast_dtype : sqlparser:: ast:: DataType ,
299
+ ) -> Self {
300
+ self . float64_ast_dtype = float64_ast_dtype;
301
+ self
302
+ }
303
+
276
304
pub fn with_utf8_cast_dtype ( mut self , utf8_cast_dtype : ast:: DataType ) -> Self {
277
305
self . utf8_cast_dtype = utf8_cast_dtype;
278
306
self
0 commit comments