milvus-io / milvus-sdk-go

Go SDK for Milvus.
Apache License 2.0
326 stars 105 forks source link

[Bug]: QueryIterator without filter expr gets error: failed to create query plan: cannot parse expression: () and int64 > 999 #763

Closed ThreadDao closed 2 months ago

ThreadDao commented 3 months ago

Is there an existing issue for this?

Current Behavior

QueryIterator with default params gets error:

2024/06/06 14:19:47 milvus_client.go:14: (ApiRequest): func [QueryIterator], args: [context.Background.WithDeadline(2024-06-06 14:21:40.651607621 +0800 CST m=+120.004409309 [1m53.490236521s]) 0xc000622ea0]
2024/06/06 14:19:47 milvus_client.go:21: (ApiResponse): func [QueryIterator], results: [0xc0003af5e0]
2024/06/06 14:19:47 response_check.go:253: QueryIterator next gets error: failed to create query plan: cannot parse expression: () and int64 > 999, error: line 1:1 mismatched input ')' expecting {'(', '[', EXISTS, '+', '-', '~', NOT, JSONContains, JSONContainsAll, JSONContainsAny, ArrayContains, ArrayContainsAll, ArrayContainsAny, ArrayLength, BooleanConstant, IntegerConstant, FloatingConstant, Identifier, StringLiteral, JSONIdentifier}: invalid parameter
itr, err := mc.QueryIterator(ctx, client.NewQueryIteratorOption(collName))

Expected Behavior

No response

Steps To Reproduce

func TestQueryIteratorBatchSize(t *testing.T) {
    ctx := createContext(t, time.Second*common.DefaultTimeout)
    // connect
    mc := createMilvusClient(ctx, t)
    // create collection
    cp := CollectionParams{CollectionFieldsType: Int64FloatVec, AutoID: false, EnableDynamicField: true,
        ShardsNum: common.DefaultShards, Dim: common.DefaultDim}
    collName := createCollection(ctx, t, mc, cp)

    // insert
    nb := 201
    dp := DataParams{CollectionName: collName, PartitionName: "", CollectionFieldsType: Int64FloatVec,
        start: 0, nb: nb, dim: common.DefaultDim, EnableDynamicField: true, WithRows: false}
    _, _ = insertData(ctx, t, mc, dp)

    idx, _ := entity.NewIndexHNSW(entity.L2, 8, 96)
    _ = mc.CreateIndex(ctx, collName, common.DefaultFloatVecFieldName, idx, false)

    // Load collection
    errLoad := mc.LoadCollection(ctx, collName, false)
    common.CheckErr(t, errLoad, true)

    type batchStruct struct {
        batch        int
        expBatchSize []int
    }
    batchStructs := []batchStruct{
        {batch: nb / 2, expBatchSize: common.GenBatchSizes(nb, nb/2)},
        {batch: nb, expBatchSize: common.GenBatchSizes(nb, nb)},
        {batch: nb + 1, expBatchSize: common.GenBatchSizes(nb, nb+1)},
    }

    for _, _batchStruct := range batchStructs {
        // query iterator with default batch
        itr, err := mc.QueryIterator(ctx, client.NewQueryIteratorOption(collName).WithBatchSize(_batchStruct.batch))
        common.CheckErr(t, err, true)
        common.CheckQueryIteratorResult(ctx, t, itr, nb, common.WithExpBatchSize(_batchStruct.expBatchSize))
    }
}


### Environment

_No response_

### Anything else?

_No response_
ThreadDao commented 3 months ago

/assign @congqixia

ThreadDao commented 2 months ago

fixed