Cloudwatch Logs: Make mixed type fields fallback to being strings (#63981)
* Cloudwatch Logs: make mixed type fields fallback to being strings * addressing pr comments
This commit is contained in:
@@ -221,6 +221,62 @@ func TestLogsResultsToDataframes(t *testing.T) {
|
||||
assert.ElementsMatch(t, expectedDataframe.Fields, dataframes.Fields)
|
||||
}
|
||||
|
||||
func TestLogsResultsToDataframes_MixedTypes_NumericValuesMixedWithStringFallBackToStringValues(t *testing.T) {
|
||||
dataframes, err := logsResultsToDataframes(&cloudwatchlogs.GetQueryResultsOutput{
|
||||
Results: [][]*cloudwatchlogs.ResultField{
|
||||
{
|
||||
&cloudwatchlogs.ResultField{
|
||||
Field: aws.String("numberOrString"),
|
||||
Value: aws.String("-1.234"),
|
||||
},
|
||||
},
|
||||
{
|
||||
&cloudwatchlogs.ResultField{
|
||||
Field: aws.String("numberOrString"),
|
||||
Value: aws.String("1"),
|
||||
},
|
||||
},
|
||||
{
|
||||
&cloudwatchlogs.ResultField{
|
||||
Field: aws.String("numberOrString"),
|
||||
Value: aws.String("not a number"),
|
||||
},
|
||||
},
|
||||
{
|
||||
&cloudwatchlogs.ResultField{
|
||||
Field: aws.String("numberOrString"),
|
||||
Value: aws.String("2.000"),
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: aws.String("ok"),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedDataframe := &data.Frame{
|
||||
Name: "CloudWatchLogsResponse",
|
||||
Fields: []*data.Field{
|
||||
data.NewField("numberOrString", nil, []*string{
|
||||
aws.String("-1.234"),
|
||||
aws.String("1"),
|
||||
aws.String("not a number"),
|
||||
aws.String("2.000"),
|
||||
}),
|
||||
},
|
||||
RefID: "",
|
||||
Meta: &data.FrameMeta{
|
||||
Custom: map[string]interface{}{
|
||||
"Status": "ok",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, expectedDataframe.Name, dataframes.Name)
|
||||
assert.Equal(t, expectedDataframe.RefID, dataframes.RefID)
|
||||
assert.Equal(t, expectedDataframe.Meta, dataframes.Meta)
|
||||
assert.ElementsMatch(t, expectedDataframe.Fields, dataframes.Fields)
|
||||
}
|
||||
|
||||
func TestGroupKeyGeneration(t *testing.T) {
|
||||
logField := data.NewField("@log", data.Labels{}, []*string{
|
||||
aws.String("fakelog-a"),
|
||||
|
||||
Reference in New Issue
Block a user