@@ -86,6 +86,12 @@ pub trait Dialect: Send + Sync {
86
86
ast:: DataType :: BigInt ( None )
87
87
}
88
88
89
+ /// The SQL type to use for Arrow Int32 unparsing
90
+ /// Most dialects use Integer, but some, like MySQL, require SIGNED
91
+ fn int32_cast_dtype ( & self ) -> ast:: DataType {
92
+ ast:: DataType :: Integer ( None )
93
+ }
94
+
89
95
/// The SQL type to use for Timestamp unparsing
90
96
/// Most dialects use Timestamp, but some, like MySQL, require Datetime
91
97
/// Some dialects like Dremio does not support WithTimeZone and requires always Timestamp
@@ -282,6 +288,10 @@ impl Dialect for MySqlDialect {
282
288
ast:: DataType :: Custom ( ObjectName ( vec ! [ Ident :: new( "SIGNED" ) ] ) , vec ! [ ] )
283
289
}
284
290
291
+ fn int32_cast_dtype ( & self ) -> ast:: DataType {
292
+ ast:: DataType :: Custom ( ObjectName ( vec ! [ Ident :: new( "SIGNED" ) ] ) , vec ! [ ] )
293
+ }
294
+
285
295
fn timestamp_cast_dtype (
286
296
& self ,
287
297
_time_unit : & TimeUnit ,
@@ -347,6 +357,7 @@ pub struct CustomDialect {
347
357
large_utf8_cast_dtype : ast:: DataType ,
348
358
date_field_extract_style : DateFieldExtractStyle ,
349
359
int64_cast_dtype : ast:: DataType ,
360
+ int32_cast_dtype : ast:: DataType ,
350
361
timestamp_cast_dtype : ast:: DataType ,
351
362
timestamp_tz_cast_dtype : ast:: DataType ,
352
363
date32_cast_dtype : sqlparser:: ast:: DataType ,
@@ -365,6 +376,7 @@ impl Default for CustomDialect {
365
376
large_utf8_cast_dtype : ast:: DataType :: Text ,
366
377
date_field_extract_style : DateFieldExtractStyle :: DatePart ,
367
378
int64_cast_dtype : ast:: DataType :: BigInt ( None ) ,
379
+ int32_cast_dtype : ast:: DataType :: Integer ( None ) ,
368
380
timestamp_cast_dtype : ast:: DataType :: Timestamp ( None , TimezoneInfo :: None ) ,
369
381
timestamp_tz_cast_dtype : ast:: DataType :: Timestamp (
370
382
None ,
@@ -424,6 +436,10 @@ impl Dialect for CustomDialect {
424
436
self . int64_cast_dtype . clone ( )
425
437
}
426
438
439
+ fn int32_cast_dtype ( & self ) -> ast:: DataType {
440
+ self . int32_cast_dtype . clone ( )
441
+ }
442
+
427
443
fn timestamp_cast_dtype (
428
444
& self ,
429
445
_time_unit : & TimeUnit ,
@@ -482,6 +498,7 @@ pub struct CustomDialectBuilder {
482
498
large_utf8_cast_dtype : ast:: DataType ,
483
499
date_field_extract_style : DateFieldExtractStyle ,
484
500
int64_cast_dtype : ast:: DataType ,
501
+ int32_cast_dtype : ast:: DataType ,
485
502
timestamp_cast_dtype : ast:: DataType ,
486
503
timestamp_tz_cast_dtype : ast:: DataType ,
487
504
date32_cast_dtype : ast:: DataType ,
@@ -506,6 +523,7 @@ impl CustomDialectBuilder {
506
523
large_utf8_cast_dtype : ast:: DataType :: Text ,
507
524
date_field_extract_style : DateFieldExtractStyle :: DatePart ,
508
525
int64_cast_dtype : ast:: DataType :: BigInt ( None ) ,
526
+ int32_cast_dtype : ast:: DataType :: Integer ( None ) ,
509
527
timestamp_cast_dtype : ast:: DataType :: Timestamp ( None , TimezoneInfo :: None ) ,
510
528
timestamp_tz_cast_dtype : ast:: DataType :: Timestamp (
511
529
None ,
@@ -527,6 +545,7 @@ impl CustomDialectBuilder {
527
545
large_utf8_cast_dtype : self . large_utf8_cast_dtype ,
528
546
date_field_extract_style : self . date_field_extract_style ,
529
547
int64_cast_dtype : self . int64_cast_dtype ,
548
+ int32_cast_dtype : self . int32_cast_dtype ,
530
549
timestamp_cast_dtype : self . timestamp_cast_dtype ,
531
550
timestamp_tz_cast_dtype : self . timestamp_tz_cast_dtype ,
532
551
date32_cast_dtype : self . date32_cast_dtype ,
@@ -604,6 +623,12 @@ impl CustomDialectBuilder {
604
623
self
605
624
}
606
625
626
+ /// Customize the dialect with a specific SQL type for Int32 casting: Integer, SIGNED, etc.
627
+ pub fn with_int32_cast_dtype ( mut self , int32_cast_dtype : ast:: DataType ) -> Self {
628
+ self . int32_cast_dtype = int32_cast_dtype;
629
+ self
630
+ }
631
+
607
632
/// Customize the dialect with a specific SQL type for Timestamp casting: Timestamp, Datetime, etc.
608
633
pub fn with_timestamp_cast_dtype (
609
634
mut self ,
0 commit comments