diff --git a/duck/duckdb.go b/duck/duckdb.go index 589dd4b..bb7f035 100644 --- a/duck/duckdb.go +++ b/duck/duckdb.go @@ -223,6 +223,14 @@ func resultsToFrame(name string, res string, f *sdk.Frame, frames []*sdk.Frame) } f.Fields = frame.Fields f.Meta = frame.Meta + return nil + } + + if kind == sdk.TimeSeriesTypeWide { + if f.Meta == nil { + f.Meta = &sdk.FrameMeta{} + } + f.Meta.Type = sdk.FrameTypeTimeSeriesWide } // TODO - appending to field names for now diff --git a/duck/duckdb_test.go b/duck/duckdb_test.go index cc283c3..f2cd14c 100644 --- a/duck/duckdb_test.go +++ b/duck/duckdb_test.go @@ -284,6 +284,36 @@ func TestTimeSeries(t *testing.T) { assert.Contains(t, txt, "Type: []time.Time") } +func TestTimeSeriesWide(t *testing.T) { + db := NewInMemoryDB() + + tt := "2024-02-23 09:01:54" + dd, err := dateparse.ParseAny(tt) + assert.Nil(t, err) + + var values = []time.Time{dd} + timeField := data.NewField("time", nil, values) + valueField := data.NewField("value", nil, []*float64{new(float64)}) + + frame := data.NewFrame("foo", timeField, valueField) + frame.RefID = "foo" + + frames := []*data.Frame{frame} + + model := &data.Frame{} + err = db.QueryFramesInto("foo", "select * from foo", frames, model) + assert.Nil(t, err) + + assert.Equal(t, data.FrameTypeTimeSeriesWide, model.Meta.Type) + + assert.Equal(t, 1, model.Rows()) + txt, err := model.StringTable(-1, -1) + assert.Nil(t, err) + + fmt.Printf("GOT: %s", txt) + assert.Contains(t, txt, "Type: []*time.Time") +} + func TestLabels(t *testing.T) { db := NewInMemoryDB()