@@ -139,36 +139,44 @@ fn unpack_and_wrap_fields(
139
139
let field_expr = sql:: ast:: Expression :: ColumnReference (
140
140
sql:: ast:: ColumnReference :: TableColumn {
141
141
table : current_table. reference . clone ( ) ,
142
- name : sql:: ast:: ColumnName ( format ! ( "{}.{}" , column_info. name. 0 . as_str( ) , field_name) ) ,
143
- }
142
+ name : sql:: ast:: ColumnName ( format ! (
143
+ "{}.{}" ,
144
+ column_info. name. 0 . as_str( ) ,
145
+ field_name
146
+ ) ) ,
147
+ } ,
144
148
) ;
145
149
let field_type_representation = match & field_type {
146
- Type :: ScalarType ( scalar_type) => env. lookup_type_representation ( scalar_type) ,
150
+ Type :: ScalarType ( scalar_type) => {
151
+ env. lookup_type_representation ( scalar_type)
152
+ }
147
153
_ => None ,
148
154
} ;
149
- let field_expr = wrap_in_type_representation ( field_expr, field_type_representation) ;
155
+ let field_expr =
156
+ wrap_in_type_representation ( field_expr, field_type_representation) ;
150
157
151
158
( field_name, field_expr)
152
159
} )
153
160
. collect ( ) ;
154
161
155
162
let json_object = sql:: ast:: Expression :: FunctionCall {
156
163
function : sql:: ast:: Function :: Unknown ( "JSON_OBJECT" . to_string ( ) ) ,
157
- args : object_fields. into_iter ( ) . flat_map ( |( k, v) | vec ! [
158
- sql:: ast:: Expression :: Value ( sql:: ast:: Value :: String ( k) ) ,
159
- v
160
- ] ) . collect ( ) ,
164
+ args : object_fields
165
+ . into_iter ( )
166
+ . flat_map ( |( k, v) | {
167
+ vec ! [ sql:: ast:: Expression :: Value ( sql:: ast:: Value :: String ( k) ) , v]
168
+ } )
169
+ . collect ( ) ,
161
170
} ;
162
171
163
172
Ok ( ( alias, json_object) )
164
173
}
165
174
Type :: RangeType ( range_type) => {
166
- let column_ref = sql :: ast :: Expression :: ColumnReference (
167
- sql:: ast:: ColumnReference :: TableColumn {
175
+ let column_ref =
176
+ sql:: ast:: Expression :: ColumnReference ( sql :: ast :: ColumnReference :: TableColumn {
168
177
table : current_table. reference . clone ( ) ,
169
178
name : column_info. name . clone ( ) ,
170
- }
171
- ) ;
179
+ } ) ;
172
180
173
181
let start_expr = sql:: ast:: Expression :: FunctionCall {
174
182
function : sql:: ast:: Function :: Unknown ( "RANGE_START" . to_string ( ) ) ,
@@ -192,12 +200,16 @@ fn unpack_and_wrap_fields(
192
200
sql:: ast:: Expression :: Value ( sql:: ast:: Value :: String ( "start" . to_string( ) ) ) ,
193
201
sql:: ast:: Expression :: Cast {
194
202
expression: Box :: new( start_expr) ,
195
- r#type: sql:: ast:: ScalarType :: BaseType ( sql:: ast:: ScalarTypeName :: Unqualified ( type_name. to_string( ) ) ) ,
203
+ r#type: sql:: ast:: ScalarType :: BaseType (
204
+ sql:: ast:: ScalarTypeName :: Unqualified ( type_name. to_string( ) ) ,
205
+ ) ,
196
206
} ,
197
207
sql:: ast:: Expression :: Value ( sql:: ast:: Value :: String ( "end" . to_string( ) ) ) ,
198
208
sql:: ast:: Expression :: Cast {
199
209
expression: Box :: new( end_expr) ,
200
- r#type: sql:: ast:: ScalarType :: BaseType ( sql:: ast:: ScalarTypeName :: Unqualified ( type_name. to_string( ) ) ) ,
210
+ r#type: sql:: ast:: ScalarType :: BaseType (
211
+ sql:: ast:: ScalarTypeName :: Unqualified ( type_name. to_string( ) ) ,
212
+ ) ,
201
213
} ,
202
214
] ,
203
215
} ;
@@ -215,36 +227,44 @@ fn unpack_and_wrap_fields(
215
227
let field_expr = sql:: ast:: Expression :: ColumnReference (
216
228
sql:: ast:: ColumnReference :: TableColumn {
217
229
table : current_table. reference . clone ( ) ,
218
- name : sql:: ast:: ColumnName ( format ! ( "{}.{}" , column_info. name. 0 . as_str( ) , field_name) ) ,
219
- }
230
+ name : sql:: ast:: ColumnName ( format ! (
231
+ "{}.{}" ,
232
+ column_info. name. 0 . as_str( ) ,
233
+ field_name
234
+ ) ) ,
235
+ } ,
220
236
) ;
221
237
let field_type_representation = match & field_type {
222
- Type :: ScalarType ( scalar_type) => env. lookup_type_representation ( scalar_type) ,
238
+ Type :: ScalarType ( scalar_type) => {
239
+ env. lookup_type_representation ( scalar_type)
240
+ }
223
241
_ => None ,
224
242
} ;
225
- let field_expr = wrap_in_type_representation ( field_expr, field_type_representation) ;
243
+ let field_expr =
244
+ wrap_in_type_representation ( field_expr, field_type_representation) ;
226
245
227
246
( field_name. clone ( ) , field_expr)
228
247
} )
229
248
. collect ( ) ;
230
249
231
250
let json_object = sql:: ast:: Expression :: FunctionCall {
232
251
function : sql:: ast:: Function :: Unknown ( "JSON_OBJECT" . to_string ( ) ) ,
233
- args : object_fields. into_iter ( ) . flat_map ( |( k, v) | vec ! [
234
- sql:: ast:: Expression :: Value ( sql:: ast:: Value :: String ( k) ) ,
235
- v
236
- ] ) . collect ( ) ,
252
+ args : object_fields
253
+ . into_iter ( )
254
+ . flat_map ( |( k, v) | {
255
+ vec ! [ sql:: ast:: Expression :: Value ( sql:: ast:: Value :: String ( k) ) , v]
256
+ } )
257
+ . collect ( ) ,
237
258
} ;
238
259
239
260
Ok ( ( alias, json_object) )
240
261
}
241
262
Type :: RangeType ( range_type) => {
242
- let column_ref = sql :: ast :: Expression :: ColumnReference (
243
- sql:: ast:: ColumnReference :: TableColumn {
263
+ let column_ref =
264
+ sql:: ast:: Expression :: ColumnReference ( sql :: ast :: ColumnReference :: TableColumn {
244
265
table : current_table. reference . clone ( ) ,
245
266
name : column_info. name . clone ( ) ,
246
- }
247
- ) ;
267
+ } ) ;
248
268
249
269
let start_expr = sql:: ast:: Expression :: FunctionCall {
250
270
function : sql:: ast:: Function :: Unknown ( "RANGE_START" . to_string ( ) ) ,
@@ -268,12 +288,16 @@ fn unpack_and_wrap_fields(
268
288
sql:: ast:: Expression :: Value ( sql:: ast:: Value :: String ( "start" . to_string( ) ) ) ,
269
289
sql:: ast:: Expression :: Cast {
270
290
expression: Box :: new( start_expr) ,
271
- r#type: sql:: ast:: ScalarType :: BaseType ( sql:: ast:: ScalarTypeName :: Unqualified ( type_name. to_string( ) ) ) ,
291
+ r#type: sql:: ast:: ScalarType :: BaseType (
292
+ sql:: ast:: ScalarTypeName :: Unqualified ( type_name. to_string( ) ) ,
293
+ ) ,
272
294
} ,
273
295
sql:: ast:: Expression :: Value ( sql:: ast:: Value :: String ( "end" . to_string( ) ) ) ,
274
296
sql:: ast:: Expression :: Cast {
275
297
expression: Box :: new( end_expr) ,
276
- r#type: sql:: ast:: ScalarType :: BaseType ( sql:: ast:: ScalarTypeName :: Unqualified ( type_name. to_string( ) ) ) ,
298
+ r#type: sql:: ast:: ScalarType :: BaseType (
299
+ sql:: ast:: ScalarTypeName :: Unqualified ( type_name. to_string( ) ) ,
300
+ ) ,
277
301
} ,
278
302
] ,
279
303
} ;
0 commit comments