diff --git a/test/common/response_check.go b/test/common/response_check.go index 1a5840dc..2d0b8531 100644 --- a/test/common/response_check.go +++ b/test/common/response_check.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "log" + "reflect" "strings" "testing" @@ -155,9 +156,15 @@ func EqualColumn(t *testing.T, columnA entity.Column, columnB entity.Column) { case entity.FieldTypeVarChar: require.ElementsMatch(t, columnA.(*entity.ColumnVarChar).Data(), columnB.(*entity.ColumnVarChar).Data()) case entity.FieldTypeJSON: - log.Printf("columnA: %s", columnA.(*entity.ColumnJSONBytes).Data()) - log.Printf("columnB: %s", columnB.(*entity.ColumnJSONBytes).Data()) - require.ElementsMatch(t, columnA.(*entity.ColumnJSONBytes).Data(), columnB.(*entity.ColumnJSONBytes).Data()) + log.Printf("columnA: %s", columnA.FieldData()) + log.Printf("columnB: %s", columnB.FieldData()) + require.Equal(t, reflect.TypeOf(columnA), reflect.TypeOf(columnB)) + switch columnA.(type) { + case *entity.ColumnDynamic: + require.ElementsMatch(t, columnA.(*entity.ColumnDynamic).Data(), columnB.(*entity.ColumnDynamic).Data()) + case *entity.ColumnJSONBytes: + require.ElementsMatch(t, columnA.(*entity.ColumnJSONBytes).Data(), columnB.(*entity.ColumnJSONBytes).Data()) + } case entity.FieldTypeFloatVector: require.ElementsMatch(t, columnA.(*entity.ColumnFloatVector).Data(), columnB.(*entity.ColumnFloatVector).Data()) case entity.FieldTypeBinaryVector: diff --git a/test/testcases/query_test.go b/test/testcases/query_test.go index 2833fad5..6e089ee3 100644 --- a/test/testcases/query_test.go +++ b/test/testcases/query_test.go @@ -984,12 +984,16 @@ func TestQueryJsonDynamicExpr(t *testing.T) { // verify output fields and count, dynamicNumber value common.CheckOutputFields(t, queryRes, []string{common.DefaultIntFieldName, common.DefaultJSONFieldName, common.DefaultDynamicNumberField}) require.Equal(t, 10, queryRes.GetColumn(common.DefaultJSONFieldName).Len()) + + // verify only output dynamic part key: common.DefaultDynamicNumberField dynamicNumColumn := queryRes.GetColumn(common.DefaultDynamicNumberField) - var numberData []int64 - for i := 0; i < dynamicNumColumn.Len(); i++ { - line, _ := dynamicNumColumn.GetAsInt64(i) - numberData = append(numberData, line) + numberValues := make([]int32, 0, 10) + for i := 0; i < 10; i++ { + numberValues = append(numberValues, int32(i)) } + _expColumn := common.MergeColumnsToDynamic(10, common.GenDynamicFieldData(0, 10)[:1], common.DefaultDynamicFieldName) + expColumn := entity.NewColumnDynamic(_expColumn, common.DefaultDynamicNumberField) + common.EqualColumn(t, dynamicNumColumn, expColumn) } // test query and output both json and dynamic field