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,18 +119,22 @@ func (fb *frameBuilder) Init(metadata *query.FluxTableMetadata) error { ...@@ -119,18 +119,22 @@ 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.timeColumn = col.Name()
fb.timeDisplay = "Time" fb.timeDisplay = "Time"
if "_time" != fb.timeColumn { if "_time" != fb.timeColumn {
fb.timeDisplay = col.Name() fb.timeDisplay = col.Name()
} }
} else { return nil
}
}
// reset any timeseries properties
fb.value = nil
fb.isTimeSeries = false
fb.labels = make([]string, 0) fb.labels = make([]string, 0)
for _, col := range columns { for _, col := range columns {
// Skip the result column // Skip the result column
...@@ -151,8 +155,6 @@ func (fb *frameBuilder) Init(metadata *query.FluxTableMetadata) error { ...@@ -151,8 +155,6 @@ func (fb *frameBuilder) Init(metadata *query.FluxTableMetadata) error {
converter: converter, 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