Commit 0bc67b03 by Ryan McKinley Committed by GitHub

InfluxDB: return a table rather than an error when timeseries is missing time (#27320)

parent ff1149ac
...@@ -119,40 +119,42 @@ func (fb *frameBuilder) Init(metadata *query.FluxTableMetadata) error { ...@@ -119,40 +119,42 @@ func (fb *frameBuilder) Init(metadata *query.FluxTableMetadata) error {
} }
} }
// Timeseries has a "_value" and a time
if fb.isTimeSeries { if fb.isTimeSeries {
col := getTimeSeriesTimeColumn(columns) col := getTimeSeriesTimeColumn(columns)
if col == nil { if col != nil {
return fmt.Errorf("no time column in timeSeries") fb.timeColumn = col.Name()
fb.timeDisplay = "Time"
if "_time" != fb.timeColumn {
fb.timeDisplay = col.Name()
}
return nil
} }
}
fb.timeColumn = col.Name() // reset any timeseries properties
fb.timeDisplay = "Time" fb.value = nil
if "_time" != fb.timeColumn { fb.isTimeSeries = false
fb.timeDisplay = col.Name() fb.labels = make([]string, 0)
for _, col := range columns {
// Skip the result column
if col.Index() == 0 && col.Name() == "result" && col.DataType() == stringDatatype {
continue
}
if col.Index() == 1 && col.Name() == "table" && col.DataType() == longDatatype {
continue
} }
} else {
fb.labels = make([]string, 0)
for _, col := range columns {
// Skip the result column
if col.Index() == 0 && col.Name() == "result" && col.DataType() == stringDatatype {
continue
}
if col.Index() == 1 && col.Name() == "table" && col.DataType() == longDatatype {
continue
}
converter, err := getConverter(col.DataType())
if err != nil {
return err
}
fb.columns = append(fb.columns, columnInfo{ converter, err := getConverter(col.DataType())
name: col.Name(), if err != nil {
converter: converter, return err
})
} }
}
fb.columns = append(fb.columns, columnInfo{
name: col.Name(),
converter: converter,
})
}
return nil return nil
} }
......
...@@ -87,6 +87,13 @@ func TestExecuteSimple(t *testing.T) { ...@@ -87,6 +87,13 @@ func TestExecuteSimple(t *testing.T) {
}) })
} }
func TestExecuteSingle(t *testing.T) {
t.Run("Single value", func(t *testing.T) {
dr := verifyGoldenResponse(t, "single")
require.Len(t, dr.Frames, 1)
})
}
func TestExecuteMultiple(t *testing.T) { func TestExecuteMultiple(t *testing.T) {
t.Run("Multiple Test", func(t *testing.T) { t.Run("Multiple Test", func(t *testing.T) {
dr := verifyGoldenResponse(t, "multiple") dr := verifyGoldenResponse(t, "multiple")
......
#group,false,false,true,false
#datatype,string,long,string,long
#default,_result,,,
,result,table,_field,_value
,,0,summary_serial_number,6
🌟 This was machine generated. Do not edit. 🌟
Frame[0] {}
Name:
Dimensions: 2 Fields by 1 Rows
+-----------------------+----------------+
| Name: _field | Name: _value |
| Labels: | Labels: |
| Type: []*string | Type: []*int64 |
+-----------------------+----------------+
| summary_serial_number | 6 |
+-----------------------+----------------+
====== TEST DATA RESPONSE (arrow base64) ======
FRAME=QVJST1cxAAD/////kAEAABAAAAAAAAoADgAMAAsABAAKAAAAFAAAAAAAAAEDAAoADAAAAAgABAAKAAAACAAAAHQAAAADAAAATAAAACgAAAAEAAAA+P7//wgAAAAMAAAAAAAAAAAAAAAFAAAAcmVmSWQAAAAY////CAAAAAwAAAAAAAAAAAAAAAQAAABuYW1lAAAAADj///8IAAAADAAAAAIAAAB7fQAABAAAAG1ldGEAAAAAAgAAAIQAAAAEAAAAlv///xQAAAA8AAAARAAAAAAAAgFIAAAAAQAAAAQAAACE////CAAAABAAAAAGAAAAX3ZhbHVlAAAEAAAAbmFtZQAAAAAAAAAACAAMAAgABwAIAAAAAAAAAUAAAAAGAAAAX3ZhbHVlAAAAABIAGAAUABMAEgAMAAAACAAEABIAAAAUAAAARAAAAEgAAAAAAAUBRAAAAAEAAAAMAAAACAAMAAgABAAIAAAACAAAABAAAAAGAAAAX2ZpZWxkAAAEAAAAbmFtZQAAAAAAAAAABAAEAAQAAAAGAAAAX2ZpZWxkAAD/////yAAAABQAAAAAAAAADAAWABQAEwAMAAQADAAAACgAAAAAAAAAFAAAAAAAAAMDAAoAGAAMAAgABAAKAAAAFAAAAGgAAAABAAAAAAAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAIAAAAAAAAABgAAAAAAAAAIAAAAAAAAAAAAAAAAAAAACAAAAAAAAAACAAAAAAAAAAAAAAAAgAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAABUAAABzdW1tYXJ5X3NlcmlhbF9udW1iZXIAAAAGAAAAAAAAABAAAAAMABQAEgAMAAgABAAMAAAAEAAAACwAAAA8AAAAAAADAAEAAACgAQAAAAAAANAAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoADAAAAAgABAAKAAAACAAAAHQAAAADAAAATAAAACgAAAAEAAAA+P7//wgAAAAMAAAAAAAAAAAAAAAFAAAAcmVmSWQAAAAY////CAAAAAwAAAAAAAAAAAAAAAQAAABuYW1lAAAAADj///8IAAAADAAAAAIAAAB7fQAABAAAAG1ldGEAAAAAAgAAAIQAAAAEAAAAlv///xQAAAA8AAAARAAAAAAAAgFIAAAAAQAAAAQAAACE////CAAAABAAAAAGAAAAX3ZhbHVlAAAEAAAAbmFtZQAAAAAAAAAACAAMAAgABwAIAAAAAAAAAUAAAAAGAAAAX3ZhbHVlAAAAABIAGAAUABMAEgAMAAAACAAEABIAAAAUAAAARAAAAEgAAAAAAAUBRAAAAAEAAAAMAAAACAAMAAgABAAIAAAACAAAABAAAAAGAAAAX2ZpZWxkAAAEAAAAbmFtZQAAAAAAAAAABAAEAAQAAAAGAAAAX2ZpZWxkAADAAQAAQVJST1cx
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment