@@ -110,6 +110,36 @@ pub trait Dialect: Send + Sync {
110110 ast:: DataType :: Integer ( None )
111111 }
112112
113+ /// The SQL type to use for Arrow Int16 unparsing
114+ /// Most dialects use SmallInt, but some, like MySQL, require SIGNED
115+ fn int16_cast_dtype ( & self ) -> ast:: DataType {
116+ ast:: DataType :: SmallInt ( None )
117+ }
118+
119+ /// The SQL type to use for Arrow UInt8 unparsing
120+ /// Most dialects use TinyIntUnsigned, but some, like MySQL, require UNSIGNED
121+ fn uint8_cast_dtype ( & self ) -> ast:: DataType {
122+ ast:: DataType :: TinyIntUnsigned ( None )
123+ }
124+
125+ /// The SQL type to use for Arrow UInt16 unparsing
126+ /// Most dialects use SmallIntUnsigned, but some, like MySQL, require UNSIGNED
127+ fn uint16_cast_dtype ( & self ) -> ast:: DataType {
128+ ast:: DataType :: SmallIntUnsigned ( None )
129+ }
130+
131+ /// The SQL type to use for Arrow UInt32 unparsing
132+ /// Most dialects use IntegerUnsigned, but some, like MySQL, require UNSIGNED
133+ fn uint32_cast_dtype ( & self ) -> ast:: DataType {
134+ ast:: DataType :: IntegerUnsigned ( None )
135+ }
136+
137+ /// The SQL type to use for Arrow UInt64 unparsing
138+ /// Most dialects use BigIntUnsigned, but some, like MySQL, require UNSIGNED
139+ fn uint64_cast_dtype ( & self ) -> ast:: DataType {
140+ ast:: DataType :: BigIntUnsigned ( None )
141+ }
142+
113143 /// The SQL type to use for Timestamp unparsing
114144 /// Most dialects use Timestamp, but some, like MySQL, require Datetime
115145 /// Some dialects like Dremio does not support WithTimeZone and requires always Timestamp
@@ -589,6 +619,26 @@ impl Dialect for MySqlDialect {
589619 ast:: DataType :: Custom ( ObjectName :: from ( vec ! [ Ident :: new( "SIGNED" ) ] ) , vec ! [ ] )
590620 }
591621
622+ fn int16_cast_dtype ( & self ) -> ast:: DataType {
623+ ast:: DataType :: Custom ( ObjectName :: from ( vec ! [ Ident :: new( "SIGNED" ) ] ) , vec ! [ ] )
624+ }
625+
626+ fn uint8_cast_dtype ( & self ) -> ast:: DataType {
627+ ast:: DataType :: Custom ( ObjectName :: from ( vec ! [ Ident :: new( "UNSIGNED" ) ] ) , vec ! [ ] )
628+ }
629+
630+ fn uint16_cast_dtype ( & self ) -> ast:: DataType {
631+ ast:: DataType :: Custom ( ObjectName :: from ( vec ! [ Ident :: new( "UNSIGNED" ) ] ) , vec ! [ ] )
632+ }
633+
634+ fn uint32_cast_dtype ( & self ) -> ast:: DataType {
635+ ast:: DataType :: Custom ( ObjectName :: from ( vec ! [ Ident :: new( "UNSIGNED" ) ] ) , vec ! [ ] )
636+ }
637+
638+ fn uint64_cast_dtype ( & self ) -> ast:: DataType {
639+ ast:: DataType :: Custom ( ObjectName :: from ( vec ! [ Ident :: new( "UNSIGNED" ) ] ) , vec ! [ ] )
640+ }
641+
592642 fn timestamp_cast_dtype (
593643 & self ,
594644 time_unit : & TimeUnit ,
@@ -843,6 +893,11 @@ pub struct CustomDialect {
843893 int8_cast_dtype : ast:: DataType ,
844894 int64_cast_dtype : ast:: DataType ,
845895 int32_cast_dtype : ast:: DataType ,
896+ int16_cast_dtype : ast:: DataType ,
897+ uint8_cast_dtype : ast:: DataType ,
898+ uint16_cast_dtype : ast:: DataType ,
899+ uint32_cast_dtype : ast:: DataType ,
900+ uint64_cast_dtype : ast:: DataType ,
846901 timestamp_cast_dtype : ast:: DataType ,
847902 timestamp_tz_cast_dtype : ast:: DataType ,
848903 date32_cast_dtype : ast:: DataType ,
@@ -870,6 +925,11 @@ impl Default for CustomDialect {
870925 int8_cast_dtype : ast:: DataType :: TinyInt ( None ) ,
871926 int64_cast_dtype : ast:: DataType :: BigInt ( None ) ,
872927 int32_cast_dtype : ast:: DataType :: Integer ( None ) ,
928+ int16_cast_dtype : ast:: DataType :: SmallInt ( None ) ,
929+ uint8_cast_dtype : ast:: DataType :: TinyIntUnsigned ( None ) ,
930+ uint16_cast_dtype : ast:: DataType :: SmallIntUnsigned ( None ) ,
931+ uint32_cast_dtype : ast:: DataType :: IntegerUnsigned ( None ) ,
932+ uint64_cast_dtype : ast:: DataType :: BigIntUnsigned ( None ) ,
873933 timestamp_cast_dtype : ast:: DataType :: Timestamp ( None , TimezoneInfo :: None ) ,
874934 timestamp_tz_cast_dtype : ast:: DataType :: Timestamp (
875935 None ,
@@ -936,6 +996,26 @@ impl Dialect for CustomDialect {
936996 self . int32_cast_dtype . clone ( )
937997 }
938998
999+ fn int16_cast_dtype ( & self ) -> ast:: DataType {
1000+ self . int16_cast_dtype . clone ( )
1001+ }
1002+
1003+ fn uint8_cast_dtype ( & self ) -> ast:: DataType {
1004+ self . uint8_cast_dtype . clone ( )
1005+ }
1006+
1007+ fn uint16_cast_dtype ( & self ) -> ast:: DataType {
1008+ self . uint16_cast_dtype . clone ( )
1009+ }
1010+
1011+ fn uint32_cast_dtype ( & self ) -> ast:: DataType {
1012+ self . uint32_cast_dtype . clone ( )
1013+ }
1014+
1015+ fn uint64_cast_dtype ( & self ) -> ast:: DataType {
1016+ self . uint64_cast_dtype . clone ( )
1017+ }
1018+
9391019 fn timestamp_cast_dtype (
9401020 & self ,
9411021 _time_unit : & TimeUnit ,
@@ -1030,6 +1110,11 @@ pub struct CustomDialectBuilder {
10301110 int8_cast_dtype : ast:: DataType ,
10311111 int64_cast_dtype : ast:: DataType ,
10321112 int32_cast_dtype : ast:: DataType ,
1113+ int16_cast_dtype : ast:: DataType ,
1114+ uint8_cast_dtype : ast:: DataType ,
1115+ uint16_cast_dtype : ast:: DataType ,
1116+ uint32_cast_dtype : ast:: DataType ,
1117+ uint64_cast_dtype : ast:: DataType ,
10331118 timestamp_cast_dtype : ast:: DataType ,
10341119 timestamp_tz_cast_dtype : ast:: DataType ,
10351120 date32_cast_dtype : ast:: DataType ,
@@ -1063,6 +1148,11 @@ impl CustomDialectBuilder {
10631148 int8_cast_dtype : ast:: DataType :: TinyInt ( None ) ,
10641149 int64_cast_dtype : ast:: DataType :: BigInt ( None ) ,
10651150 int32_cast_dtype : ast:: DataType :: Integer ( None ) ,
1151+ int16_cast_dtype : ast:: DataType :: SmallInt ( None ) ,
1152+ uint8_cast_dtype : ast:: DataType :: TinyIntUnsigned ( None ) ,
1153+ uint16_cast_dtype : ast:: DataType :: SmallIntUnsigned ( None ) ,
1154+ uint32_cast_dtype : ast:: DataType :: IntegerUnsigned ( None ) ,
1155+ uint64_cast_dtype : ast:: DataType :: BigIntUnsigned ( None ) ,
10661156 timestamp_cast_dtype : ast:: DataType :: Timestamp ( None , TimezoneInfo :: None ) ,
10671157 timestamp_tz_cast_dtype : ast:: DataType :: Timestamp (
10681158 None ,
@@ -1093,6 +1183,11 @@ impl CustomDialectBuilder {
10931183 int8_cast_dtype : self . int8_cast_dtype ,
10941184 int64_cast_dtype : self . int64_cast_dtype ,
10951185 int32_cast_dtype : self . int32_cast_dtype ,
1186+ int16_cast_dtype : self . int16_cast_dtype ,
1187+ uint8_cast_dtype : self . uint8_cast_dtype ,
1188+ uint16_cast_dtype : self . uint16_cast_dtype ,
1189+ uint32_cast_dtype : self . uint32_cast_dtype ,
1190+ uint64_cast_dtype : self . uint64_cast_dtype ,
10961191 timestamp_cast_dtype : self . timestamp_cast_dtype ,
10971192 timestamp_tz_cast_dtype : self . timestamp_tz_cast_dtype ,
10981193 date32_cast_dtype : self . date32_cast_dtype ,
@@ -1194,6 +1289,36 @@ impl CustomDialectBuilder {
11941289 self
11951290 }
11961291
1292+ /// Customize the dialect with a specific SQL type for Int16 casting: SmallInt, SIGNED, etc.
1293+ pub fn with_int16_cast_dtype ( mut self , int16_cast_dtype : ast:: DataType ) -> Self {
1294+ self . int16_cast_dtype = int16_cast_dtype;
1295+ self
1296+ }
1297+
1298+ /// Customize the dialect with a specific SQL type for UInt8 casting: TinyIntUnsigned, UNSIGNED, etc.
1299+ pub fn with_uint8_cast_dtype ( mut self , uint8_cast_dtype : ast:: DataType ) -> Self {
1300+ self . uint8_cast_dtype = uint8_cast_dtype;
1301+ self
1302+ }
1303+
1304+ /// Customize the dialect with a specific SQL type for UInt16 casting: SmallIntUnsigned, UNSIGNED, etc.
1305+ pub fn with_uint16_cast_dtype ( mut self , uint16_cast_dtype : ast:: DataType ) -> Self {
1306+ self . uint16_cast_dtype = uint16_cast_dtype;
1307+ self
1308+ }
1309+
1310+ /// Customize the dialect with a specific SQL type for UInt32 casting: IntegerUnsigned, UNSIGNED, etc.
1311+ pub fn with_uint32_cast_dtype ( mut self , uint32_cast_dtype : ast:: DataType ) -> Self {
1312+ self . uint32_cast_dtype = uint32_cast_dtype;
1313+ self
1314+ }
1315+
1316+ /// Customize the dialect with a specific SQL type for UInt64 casting: BigIntUnsigned, UNSIGNED, etc.
1317+ pub fn with_uint64_cast_dtype ( mut self , uint64_cast_dtype : ast:: DataType ) -> Self {
1318+ self . uint64_cast_dtype = uint64_cast_dtype;
1319+ self
1320+ }
1321+
11971322 /// Customize the dialect with a specific SQL type for Timestamp casting: Timestamp, Datetime, etc.
11981323 pub fn with_timestamp_cast_dtype (
11991324 mut self ,
0 commit comments