Skip to content

Commit

Permalink
enhance: [Cherry-Pick] Remove varchar column cannot use auto ID const…
Browse files Browse the repository at this point in the history
…raint (#665) (#667)

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Feb 20, 2024
1 parent beb42ed commit e19ce19
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
3 changes: 0 additions & 3 deletions client/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 0 additions & 7 deletions client/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
7 changes: 3 additions & 4 deletions test/testcases/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down

0 comments on commit e19ce19

Please sign in to comment.