Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: update case to check output dynamic key #821

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions test/common/response_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"log"
"reflect"
"strings"
"testing"

Expand Down Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions test/testcases/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading