Support input empty string (#19111) (#19144)

Signed-off-by: yhmo <yihua.mo@zilliz.com>

Signed-off-by: yhmo <yihua.mo@zilliz.com>

Signed-off-by: yhmo <yihua.mo@zilliz.com>
This commit is contained in:
groot 2022-09-13 13:36:29 +08:00 committed by GitHub
parent ec48e2405a
commit b161aec95e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 23 deletions

View File

@ -280,14 +280,11 @@ func (w *PayloadWriter) AddDoubleToPayload(msgs []float64) error {
func (w *PayloadWriter) AddOneStringToPayload(msg string) error {
length := len(msg)
if length == 0 {
return errors.New("can't add empty string into payload")
}
cmsg := C.CString(msg)
clength := C.int(length)
defer C.free(unsafe.Pointer(cmsg))
// the C.AddOneStringToPayload can handle empty string
status := C.AddOneStringToPayload(w.payloadWriterPtr, cmsg, clength)
return HandleCStatus(&status, "AddOneStringToPayload failed")
}

View File

@ -567,7 +567,7 @@ func TestPayload_CGO_ReaderandWriter(t *testing.T) {
assert.NotNil(t, err)
err = w.AddOneStringToPayload("")
assert.NotNil(t, err)
assert.Nil(t, err)
err = w.FinishPayloadWriter()
assert.Nil(t, err)
err = w.AddOneStringToPayload("c")

View File

@ -567,7 +567,7 @@ func TestPayload_ReaderAndWriter(t *testing.T) {
assert.NotNil(t, err)
err = w.AddOneStringToPayload("")
assert.NotNil(t, err)
assert.Nil(t, err)
err = w.FinishPayloadWriter()
assert.Nil(t, err)
err = w.AddOneStringToPayload("c")

View File

@ -1202,23 +1202,6 @@ class TestInsertString(TestcaseBase):
error = {ct.err_code: 0, ct.err_msg: 'Data type is not support.'}
collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="https://github.com/milvus-io/milvus/issues/18872, need to fix")
def test_insert_string_field_empty(self):
"""
target: test create collection with string field
method: 1.create a collection
2.Insert string field with empty data
expected: raise an error
"""
c_name = cf.gen_unique_str(prefix)
collection_w = self.init_collection_wrap(name=c_name)
nb = 1000
data = cf.gen_default_list_data(nb)
data[2] = [""for _ in range(nb)]
collection_w.insert(data)
assert collection_w.num_entities == nb
@pytest.mark.tags(CaseLabel.L1)
def test_insert_string_field_space(self):
"""