test: add json and array datatype check in restful v1 (#31097)

* When the collection is created using an SDK and includes array and
JSON datatypes in the schema, data can be inserted using the RESTful
API.
* When the collection is created using the RESTful API and includes JSON
and array datatypes in dynamic fields, data can also be inserted using
the RESTful API.

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
pull/30824/head
zhuwenxing 2024-03-08 10:27:01 +08:00 committed by GitHub
parent 0a2655dba0
commit cc51ab9cd9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View File

@ -138,6 +138,9 @@ class TestRestfulSdkCompatibility(TestBase):
FieldSchema(name="int64", dtype=DataType.INT64, is_primary=True),
FieldSchema(name="float", dtype=DataType.FLOAT),
FieldSchema(name="varchar", dtype=DataType.VARCHAR, max_length=65535),
FieldSchema(name="json", dtype=DataType.JSON),
FieldSchema(name="int_array", dtype=DataType.ARRAY, element_type=DataType.INT64, max_capacity=1024),
FieldSchema(name="varchar_array", dtype=DataType.ARRAY, element_type=DataType.VARCHAR, max_capacity=1024, max_length=65535),
FieldSchema(name="float_vector", dtype=DataType.FLOAT_VECTOR, dim=128)
]
default_schema = CollectionSchema(fields=default_fields, description="test collection",
@ -149,7 +152,14 @@ class TestRestfulSdkCompatibility(TestBase):
collection.load()
# insert data by restful
data = [
{"int64": i, "float": i, "varchar": str(i), "float_vector": [random.random() for _ in range(dim)], "age": i}
{"int64": i,
"float": i,
"varchar": str(i),
"json": {"name": "name", "age": i},
"int_array": [i for i in range(10)],
"varchar_array": [str(i) for i in range(10)],
"float_vector": [random.random() for _ in range(dim)],
"age": i}
for i in range(nb)
]
client = self.vector_client

View File

@ -96,6 +96,8 @@ def get_random_json_data(uid=None):
uid = 0
data = {"uid": uid, "name": fake.name(), "address": fake.address(), "text": fake.text(), "email": fake.email(),
"phone_number": fake.phone_number(),
"array_int_dynamic": [random.randint(1, 100_000) for i in range(random.randint(1, 10))],
"array_varchar_dynamic": [fake.name() for i in range(random.randint(1, 10))],
"json": {
"name": fake.name(),
"address": fake.address()