@@ -13,6 +13,7 @@ import (
13
13
"github.com/featurebasedb/featurebase/v3/dax"
14
14
"github.com/featurebasedb/featurebase/v3/pql"
15
15
"github.com/featurebasedb/featurebase/v3/sql3"
16
+ "github.com/featurebasedb/featurebase/v3/sql3/parser"
16
17
"github.com/featurebasedb/featurebase/v3/sql3/planner/types"
17
18
"github.com/pkg/errors"
18
19
)
@@ -253,9 +254,9 @@ func (i *insertRowIter) Next(ctx context.Context) (types.Row, error) {
253
254
}
254
255
255
256
case pilosa .FieldTypeTime :
256
- row .Time = qbatchTime
257
257
switch v := eval .(type ) {
258
258
case []int64 :
259
+ row .Time = qbatchTime
259
260
uint64s := make ([]uint64 , len (v ))
260
261
for i := range v {
261
262
if v [i ] < 0 {
@@ -264,6 +265,59 @@ func (i *insertRowIter) Next(ctx context.Context) (types.Row, error) {
264
265
uint64s [i ] = uint64 (v [i ])
265
266
}
266
267
row.Values [posVals [idx ]] = uint64s
268
+
269
+ case []interface {}:
270
+ // it's a tuple, check length
271
+ if len (v ) != 2 {
272
+ return nil , sql3 .NewErrUnexpectedTimeQuantumTupleLength (0 , 0 , columnName , rowNumber + 1 , v , len (v ))
273
+ }
274
+
275
+ tupleType , ok := iv .Type ().(* parser.DataTypeTuple )
276
+ if ! ok {
277
+ return nil , sql3 .NewErrInternalf ("unexpected tuple type '%T'" , v [0 ])
278
+ }
279
+
280
+ // first member must be a timestamp or coercable as one
281
+ cval , err := coerceValue (tupleType .Members [0 ], parser .NewDataTypeTimestamp (), v [0 ], parser.Pos {Line : 0 , Column : 0 })
282
+ if err != nil {
283
+ return nil , err
284
+ }
285
+ tval , ok := cval .(time.Time )
286
+ if ! ok {
287
+ return nil , sql3 .NewErrInternalf ("unexpected tuple time value type '%T'" , v [0 ])
288
+ }
289
+ var qrowTime fbbatch.QuantizedTime
290
+ qrowTime .Set (tval )
291
+ row .Time = qrowTime
292
+
293
+ // second member must be a set of the correct type
294
+ targetCol := i .targetColumns [idx ]
295
+
296
+ switch targetCol .Type ().(type ) {
297
+ case * parser.DataTypeStringSetQuantum :
298
+ sval , ok := v [1 ].([]string )
299
+ if ! ok {
300
+ return nil , sql3 .NewErrInternalf ("string set type expected '%T'" , v [1 ])
301
+ }
302
+ row.Values [posVals [idx ]] = sval
303
+
304
+ case * parser.DataTypeIDSetQuantum :
305
+ sval , ok := v [1 ].([]int64 )
306
+ if ! ok {
307
+ return nil , sql3 .NewErrInternalf ("id set type expected '%T'" , v [1 ])
308
+ }
309
+ uint64s := make ([]uint64 , len (sval ))
310
+ for i := range sval {
311
+ if sval [i ] < 0 {
312
+ return nil , sql3 .NewErrInternalf ("converting negative slice value to uint64: %d" , sval [i ])
313
+ }
314
+ uint64s [i ] = uint64 (sval [i ])
315
+ }
316
+ row.Values [posVals [idx ]] = uint64s
317
+
318
+ default :
319
+ return nil , sql3 .NewErrInternalf ("unexpected set type '%T'" , targetCol .Type ())
320
+ }
267
321
default :
268
322
row.Values [posVals [idx ]] = eval
269
323
}
0 commit comments