1
1
use ion_rs:: IonError ;
2
2
use miette:: Diagnostic ;
3
3
use partiql_types:: {
4
- AnyOf , ArrayType , BagType , PartiqlShape , ShapeResultError , StaticType , StaticTypeVariant ,
5
- StructType ,
4
+ AnyOf , ArrayType , BagType , PartiqlShape , ShapeResultError , Static , StaticType , StructType ,
6
5
} ;
7
6
use std:: fmt:: { Display , Formatter } ;
8
7
use std:: string:: ToString ;
@@ -111,22 +110,21 @@ impl PartiqlBasicDdlEncoder {
111
110
let mut out = String :: new ( ) ;
112
111
113
112
match ty. ty ( ) {
114
- StaticTypeVariant :: Int => out. push_str ( "INT" ) ,
115
- StaticTypeVariant :: Int8 => out. push_str ( "TINYINT" ) ,
116
- StaticTypeVariant :: Int16 => out. push_str ( "SMALLINT" ) ,
117
- StaticTypeVariant :: Int32 => out. push_str ( "INTEGER" ) ,
118
- StaticTypeVariant :: Int64 => out. push_str ( "INT8" ) ,
119
- StaticTypeVariant :: Bool => out. push_str ( "BOOL" ) ,
120
- StaticTypeVariant :: Decimal => out. push_str ( "DECIMAL" ) ,
121
- StaticTypeVariant :: DecimalP ( p, s) => out. push_str ( & format ! ( "DECIMAL({p}, {s})" ) ) ,
122
- StaticTypeVariant :: DateTime => out. push_str ( "TIMESTAMP" ) ,
123
- StaticTypeVariant :: Float32 => out. push_str ( "REAL" ) ,
124
- StaticTypeVariant :: Float64 => out. push_str ( "DOUBLE" ) ,
125
- StaticTypeVariant :: String => out. push_str ( "VARCHAR" ) ,
126
- StaticTypeVariant :: Struct ( s) => out. push_str ( & self . write_struct ( & s) ?) ,
127
- StaticTypeVariant :: Bag ( b) => out. push_str ( & self . write_bag ( & b) ?) ,
128
- StaticTypeVariant :: Array ( a) => out. push_str ( & self . write_array ( & a) ?) ,
129
-
113
+ Static :: Int => out. push_str ( "INT" ) ,
114
+ Static :: Int8 => out. push_str ( "TINYINT" ) ,
115
+ Static :: Int16 => out. push_str ( "SMALLINT" ) ,
116
+ Static :: Int32 => out. push_str ( "INTEGER" ) ,
117
+ Static :: Int64 => out. push_str ( "INT8" ) ,
118
+ Static :: Bool => out. push_str ( "BOOL" ) ,
119
+ Static :: Decimal => out. push_str ( "DECIMAL" ) ,
120
+ Static :: DecimalP ( p, s) => out. push_str ( & format ! ( "DECIMAL({p}, {s})" ) ) ,
121
+ Static :: DateTime => out. push_str ( "TIMESTAMP" ) ,
122
+ Static :: Float32 => out. push_str ( "REAL" ) ,
123
+ Static :: Float64 => out. push_str ( "DOUBLE" ) ,
124
+ Static :: String => out. push_str ( "VARCHAR" ) ,
125
+ Static :: Struct ( s) => out. push_str ( & self . write_struct ( & s) ?) ,
126
+ Static :: Bag ( b) => out. push_str ( & self . write_bag ( & b) ?) ,
127
+ Static :: Array ( a) => out. push_str ( & self . write_array ( & a) ?) ,
130
128
// non-exhaustive catch-all
131
129
_ => todo ! ( "handle type for {}" , ty) ,
132
130
}
@@ -192,7 +190,7 @@ impl PartiqlDdlEncoder for PartiqlBasicDdlEncoder {
192
190
let mut output = String :: new ( ) ;
193
191
let ty = ty. expect_static ( ) ?;
194
192
195
- if let StaticTypeVariant :: Bag ( bag) = ty. ty ( ) {
193
+ if let Static :: Bag ( bag) = ty. ty ( ) {
196
194
let s = bag. element_type ( ) . expect_struct ( ) ?;
197
195
let fields = s. fields ( ) ;
198
196
let mut fields = fields. iter ( ) . peekable ( ) ;
@@ -235,8 +233,8 @@ mod tests {
235
233
(
236
234
"a" ,
237
235
PartiqlShape :: any_of( vec![
238
- PartiqlShape :: new( StaticTypeVariant :: DecimalP ( 5 , 4 ) ) ,
239
- PartiqlShape :: new( StaticTypeVariant :: Int8 ) ,
236
+ PartiqlShape :: new( Static :: DecimalP ( 5 , 4 ) ) ,
237
+ PartiqlShape :: new( Static :: Int8 ) ,
240
238
] )
241
239
) ,
242
240
( "b" , array![ str ![ ] ] ) ,
@@ -247,10 +245,7 @@ mod tests {
247
245
let fields = struct_fields ! [
248
246
( "employee_id" , int8![ ] ) ,
249
247
( "full_name" , str ![ ] ) ,
250
- (
251
- "salary" ,
252
- PartiqlShape :: new( StaticTypeVariant :: DecimalP ( 8 , 2 ) )
253
- ) ,
248
+ ( "salary" , PartiqlShape :: new( Static :: DecimalP ( 8 , 2 ) ) ) ,
254
249
( "details" , details) ,
255
250
( "dependents" , array![ str ![ ] ] )
256
251
] ;
0 commit comments