enhance: Add back unit test for compactor and fix some TODOs (#31829)

This PR adds back compactor "Unhandled" data type unit test and fixes
some TODOs behvaior

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/31848/head
congqixia 2024-04-02 20:35:14 +08:00 committed by GitHub
parent 246586be27
commit 0feee53631
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 22 deletions

View File

@ -719,15 +719,12 @@ func interface2FieldData(schemaDataType schemapb.DataType, content []interface{}
Data: make([]*schemapb.ScalarField, 0, len(content)),
}
if len(content) > 0 {
data.ElementType = content[0].(*schemapb.ScalarField).GetArrayData().GetElementType()
}
for _, c := range content {
r, ok := c.(*schemapb.ScalarField)
if !ok {
return nil, errTransferType
}
data.ElementType = r.GetArrayData().GetElementType()
data.Data = append(data.Data, r)
}
rst = data

View File

@ -116,17 +116,16 @@ func TestCompactionTaskInnerMethods(t *testing.T) {
}
// make sure all new data types missed to handle would throw unexpected error
// todo(yah01): enable this after the BF16 vector type ready
// for typeName, typeValue := range schemapb.DataType_value {
// tests = append(tests, struct {
// isvalid bool
for typeName, typeValue := range schemapb.DataType_value {
tests = append(tests, struct {
isvalid bool
// tp schemapb.DataType
// content []interface{}
tp schemapb.DataType
content []interface{}
// description string
// }{false, schemapb.DataType(typeValue), []interface{}{nil, nil}, "invalid " + typeName})
// }
description string
}{false, schemapb.DataType(typeValue), []interface{}{nil, nil}, "invalid " + typeName})
}
for _, test := range tests {
t.Run(test.description, func(t *testing.T) {
@ -136,7 +135,7 @@ func TestCompactionTaskInnerMethods(t *testing.T) {
assert.Equal(t, 2, fd.RowNum())
} else {
fd, err := interface2FieldData(test.tp, test.content, 2)
assert.ErrorIs(t, err, errTransferType)
assert.True(t, errors.Is(err, errTransferType) || errors.Is(err, errUnknownDataType))
assert.Nil(t, fd)
}
})

View File

@ -17,7 +17,6 @@
package utils
import (
"fmt"
"math/rand"
"sort"
@ -62,8 +61,7 @@ func GetPartitions(collectionMgr *meta.CollectionManager, collectionID int64) ([
}
}
// todo(yah01): replace this error with a defined error
return nil, fmt.Errorf("collection/partition not loaded")
return nil, merr.WrapErrCollectionNotLoaded(collectionID)
}
// GroupNodesByReplica groups nodes by replica,

View File

@ -1,8 +1,10 @@
// Copyright 2023 yah01
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// Licensed to the LF AI & Data foundation under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//