@@ -83,15 +83,14 @@ impl JsonEncoder {
83
83
pub fn new_with_doris (
84
84
schema : Schema ,
85
85
col_indices : Option < Vec < usize > > ,
86
- timestamp_handling_mode : TimestampHandlingMode ,
87
86
map : HashMap < String , ( u8 , u8 ) > ,
88
87
) -> Self {
89
88
Self {
90
89
schema,
91
90
col_indices,
92
91
time_handling_mode : TimeHandlingMode :: Milli ,
93
92
date_handling_mode : DateHandlingMode :: String ,
94
- timestamp_handling_mode,
93
+ timestamp_handling_mode : TimestampHandlingMode :: String ,
95
94
timestamptz_handling_mode : TimestamptzHandlingMode :: UtcWithoutSuffix ,
96
95
custom_json_type : CustomJsonType :: Doris ( map) ,
97
96
kafka_connect : None ,
@@ -101,21 +100,33 @@ impl JsonEncoder {
101
100
pub fn new_with_starrocks (
102
101
schema : Schema ,
103
102
col_indices : Option < Vec < usize > > ,
104
- timestamp_handling_mode : TimestampHandlingMode ,
105
103
map : HashMap < String , ( u8 , u8 ) > ,
106
104
) -> Self {
107
105
Self {
108
106
schema,
109
107
col_indices,
110
108
time_handling_mode : TimeHandlingMode :: Milli ,
111
109
date_handling_mode : DateHandlingMode :: String ,
112
- timestamp_handling_mode,
110
+ timestamp_handling_mode : TimestampHandlingMode :: String ,
113
111
timestamptz_handling_mode : TimestamptzHandlingMode :: UtcWithoutSuffix ,
114
112
custom_json_type : CustomJsonType :: StarRocks ( map) ,
115
113
kafka_connect : None ,
116
114
}
117
115
}
118
116
117
+ pub fn new_with_bigquery ( schema : Schema , col_indices : Option < Vec < usize > > ) -> Self {
118
+ Self {
119
+ schema,
120
+ col_indices,
121
+ time_handling_mode : TimeHandlingMode :: Milli ,
122
+ date_handling_mode : DateHandlingMode :: String ,
123
+ timestamp_handling_mode : TimestampHandlingMode :: String ,
124
+ timestamptz_handling_mode : TimestamptzHandlingMode :: UtcString ,
125
+ custom_json_type : CustomJsonType :: BigQuery ,
126
+ kafka_connect : None ,
127
+ }
128
+ }
129
+
119
130
pub fn with_kafka_connect ( self , kafka_connect : KafkaConnectParams ) -> Self {
120
131
Self {
121
132
kafka_connect : Some ( Arc :: new ( kafka_connect) ) ,
@@ -192,7 +203,15 @@ fn datum_to_json_object(
192
203
custom_json_type : & CustomJsonType ,
193
204
) -> ArrayResult < Value > {
194
205
let scalar_ref = match datum {
195
- None => return Ok ( Value :: Null ) ,
206
+ None => {
207
+ if let CustomJsonType :: BigQuery = custom_json_type
208
+ && matches ! ( field. data_type( ) , DataType :: List ( _) )
209
+ {
210
+ return Ok ( Value :: Array ( vec ! [ ] ) ) ;
211
+ } else {
212
+ return Ok ( Value :: Null ) ;
213
+ }
214
+ }
196
215
Some ( datum) => datum,
197
216
} ;
198
217
@@ -239,7 +258,7 @@ fn datum_to_json_object(
239
258
}
240
259
json ! ( v_string)
241
260
}
242
- CustomJsonType :: Es | CustomJsonType :: None => {
261
+ CustomJsonType :: Es | CustomJsonType :: None | CustomJsonType :: BigQuery => {
243
262
json ! ( v. to_text( ) )
244
263
}
245
264
} ,
@@ -291,7 +310,7 @@ fn datum_to_json_object(
291
310
}
292
311
( DataType :: Jsonb , ScalarRefImpl :: Jsonb ( jsonb_ref) ) => match custom_json_type {
293
312
CustomJsonType :: Es | CustomJsonType :: StarRocks ( _) => JsonbVal :: from ( jsonb_ref) . take ( ) ,
294
- CustomJsonType :: Doris ( _) | CustomJsonType :: None => {
313
+ CustomJsonType :: Doris ( _) | CustomJsonType :: None | CustomJsonType :: BigQuery => {
295
314
json ! ( jsonb_ref. to_string( ) )
296
315
}
297
316
} ,
@@ -342,7 +361,7 @@ fn datum_to_json_object(
342
361
"starrocks can't support struct" . to_string ( ) ,
343
362
) ) ;
344
363
}
345
- CustomJsonType :: Es | CustomJsonType :: None => {
364
+ CustomJsonType :: Es | CustomJsonType :: None | CustomJsonType :: BigQuery => {
346
365
let mut map = Map :: with_capacity ( st. len ( ) ) ;
347
366
for ( sub_datum_ref, sub_field) in struct_ref. iter_fields_ref ( ) . zip_eq_debug (
348
367
st. iter ( )
0 commit comments