diff --git a/client/collection.go b/client/collection.go index 6fbec973..a21188a2 100644 --- a/client/collection.go +++ b/client/collection.go @@ -204,9 +204,6 @@ func (c *GrpcClient) validateSchema(sch *entity.Schema) error { if autoID { return errors.New("only one auto id is available") } - if field.DataType != entity.FieldTypeInt64 { - return errors.New("only int64 column can be auto generated id") - } autoID = true } if field.DataType == entity.FieldTypeJSON { diff --git a/client/collection_test.go b/client/collection_test.go index edfe788d..745f0761 100644 --- a/client/collection_test.go +++ b/client/collection_test.go @@ -374,13 +374,6 @@ func (s *CollectionSuite) TestNewCollection() { err := c.NewCollection(ctx, testCollectionName, testVectorDim, WithPKFieldName("my_pk"), WithPKFieldType(entity.FieldTypeVarChar), WithVectorFieldName("embedding"), WithConsistencyLevel(entity.ClEventually)) s.NoError(err) }) - - s.Run("varchar_autoid", func() { - defer s.resetMock() - - err := c.NewCollection(ctx, testCollectionName, testVectorDim, WithPKFieldType(entity.FieldTypeVarChar), WithAutoID(true)) - s.Error(err) - }) } func (s *CollectionSuite) TestRenameCollection() { diff --git a/test/testcases/collection_test.go b/test/testcases/collection_test.go index 2cd6cb48..9ef77202 100644 --- a/test/testcases/collection_test.go +++ b/test/testcases/collection_test.go @@ -220,20 +220,19 @@ func TestCreateCollectionNonInt64AutoField(t *testing.T) { entity.FieldTypeInt32, entity.FieldTypeFloat, entity.FieldTypeDouble, - entity.FieldTypeVarChar, + // entity.FieldTypeVarChar, entity.FieldTypeString, entity.FieldTypeNone, entity.FieldTypeJSON, } for _, fieldType := range invalidPkFields { fields := []*entity.Field{ - common.GenField("non-auto-id", fieldType, common.WithAutoID(true)), - common.GenField(common.DefaultIntFieldName, entity.FieldTypeInt64, common.WithIsPrimaryKey(true), common.WithAutoID(true)), + common.GenField(common.DefaultIntFieldName, fieldType, common.WithIsPrimaryKey(true), common.WithAutoID(true)), common.GenField(common.DefaultFloatVecFieldName, entity.FieldTypeFloatVector, common.WithDim(common.DefaultDim)), } schema := common.GenSchema(common.GenRandomString(6), true, fields) errNonInt64Field := mc.CreateCollection(ctx, schema, common.DefaultShards) - common.CheckErr(t, errNonInt64Field, false, "only int64 column can be auto generated id") + common.CheckErr(t, errNonInt64Field, false, "only int64 and varchar column can be primary key for now") } }