@@ -46,42 +46,60 @@ macro_rules! type_dynamic {
46
46
#[ macro_export]
47
47
macro_rules! type_int {
48
48
( ) => {
49
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: Int )
49
+ type_int!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
50
+ } ;
51
+ ( $bld: expr) => {
52
+ $bld. new_static( $crate:: Static :: Int )
50
53
} ;
51
54
}
52
55
53
56
#[ macro_export]
54
57
macro_rules! type_int8 {
55
58
( ) => {
56
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: Int8 )
59
+ type_int8!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
60
+ } ;
61
+ ( $bld: expr) => {
62
+ $bld. new_static( $crate:: Static :: Int8 )
57
63
} ;
58
64
}
59
65
60
66
#[ macro_export]
61
67
macro_rules! type_int16 {
62
68
( ) => {
63
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: Int16 )
69
+ type_int16!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
70
+ } ;
71
+ ( $bld: expr) => {
72
+ $bld. new_static( $crate:: Static :: Int16 )
64
73
} ;
65
74
}
66
75
67
76
#[ macro_export]
68
77
macro_rules! type_int32 {
69
78
( ) => {
70
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: Int32 )
79
+ type_int32!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
80
+ } ;
81
+ ( $bld: expr) => {
82
+ $bld. new_static( $crate:: Static :: Int32 )
71
83
} ;
72
84
}
73
85
74
86
#[ macro_export]
75
87
macro_rules! type_int64 {
76
88
( ) => {
77
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: Int64 )
89
+ type_int64!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
90
+ } ;
91
+ ( $bld: expr) => {
92
+ $bld. new_static( $crate:: Static :: Int64 )
78
93
} ;
79
94
}
80
95
81
96
#[ macro_export]
82
97
macro_rules! type_decimal {
83
98
( ) => {
84
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: Decimal )
99
+ type_decimal!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
100
+ } ;
101
+ ( $bld: expr) => {
102
+ $bld. new_static( $crate:: Static :: Decimal )
85
103
} ;
86
104
}
87
105
@@ -90,28 +108,40 @@ macro_rules! type_decimal {
90
108
#[ macro_export]
91
109
macro_rules! type_float32 {
92
110
( ) => {
93
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: Float32 )
111
+ type_float32!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
112
+ } ;
113
+ ( $bld: expr) => {
114
+ $bld. new_static( $crate:: Static :: Float32 )
94
115
} ;
95
116
}
96
117
97
118
#[ macro_export]
98
119
macro_rules! type_float64 {
99
120
( ) => {
100
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: Float64 )
121
+ type_float64!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
122
+ } ;
123
+ ( $bld: expr) => {
124
+ $bld. new_static( $crate:: Static :: Float64 )
101
125
} ;
102
126
}
103
127
104
128
#[ macro_export]
105
129
macro_rules! type_string {
106
130
( ) => {
107
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: String )
131
+ type_string!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
132
+ } ;
133
+ ( $bld: expr) => {
134
+ $bld. new_static( $crate:: Static :: String )
108
135
} ;
109
136
}
110
137
111
138
#[ macro_export]
112
139
macro_rules! type_bool {
113
140
( ) => {
114
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: Bool )
141
+ type_bool!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
142
+ } ;
143
+ ( $bld: expr) => {
144
+ $bld. new_static( $crate:: Static :: Bool )
115
145
} ;
116
146
}
117
147
@@ -130,7 +160,10 @@ macro_rules! type_numeric {
130
160
#[ macro_export]
131
161
macro_rules! type_datetime {
132
162
( ) => {
133
- $crate:: PartiqlShapeBuilder :: init_or_get( ) . new_static( $crate:: Static :: DateTime )
163
+ type_datetime!( $crate:: PartiqlShapeBuilder :: init_or_get( ) )
164
+ } ;
165
+ ( $bld: expr) => {
166
+ $bld. new_static( $crate:: Static :: DateTime )
134
167
} ;
135
168
}
136
169
@@ -505,6 +538,14 @@ impl PartiqlShapeBuilder {
505
538
self . new_static ( Static :: Bag ( b) )
506
539
}
507
540
541
+ #[ must_use]
542
+ pub fn new_bag_of < E > ( & self , element_type : E ) -> PartiqlShape
543
+ where
544
+ E : Into < PartiqlShape > ,
545
+ {
546
+ self . new_bag ( BagType :: new_of ( element_type) )
547
+ }
548
+
508
549
#[ must_use]
509
550
pub fn new_array ( & self , a : ArrayType ) -> PartiqlShape {
510
551
self . new_static ( Static :: Array ( a) )
@@ -610,6 +651,12 @@ impl StaticType {
610
651
}
611
652
}
612
653
654
+ impl From < StaticType > for PartiqlShape {
655
+ fn from ( value : StaticType ) -> Self {
656
+ PartiqlShape :: Static ( value)
657
+ }
658
+ }
659
+
613
660
impl Display for StaticType {
614
661
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
615
662
let ty = & self . ty ;
@@ -862,17 +909,23 @@ pub struct BagType {
862
909
}
863
910
864
911
impl BagType {
865
- #[ must_use ]
912
+ #[ inline ]
866
913
pub fn new_any ( ) -> Self {
867
- BagType :: new ( Box :: new ( PartiqlShape :: Dynamic ) )
914
+ Self :: new_of ( PartiqlShape :: Dynamic )
868
915
}
869
916
870
- #[ must_use ]
917
+ #[ inline ]
871
918
pub fn new ( typ : Box < PartiqlShape > ) -> Self {
872
919
BagType { element_type : typ }
873
920
}
874
921
875
- #[ must_use]
922
+ pub fn new_of < E > ( element_type : E ) -> Self
923
+ where
924
+ E : Into < PartiqlShape > ,
925
+ {
926
+ Self :: new ( Box :: new ( element_type. into ( ) ) )
927
+ }
928
+
876
929
pub fn element_type ( & self ) -> & PartiqlShape {
877
930
& self . element_type
878
931
}
0 commit comments