milvus-io / milvus

A cloud-native vector database, storage for next generation AI applications
https://milvus.io
Apache License 2.0
29.95k stars 2.87k forks source link

[Bug]: [null & default] Insert rows report error "undefined data type:Int64: invalid parameter" when insert without the default value field #36485

Closed binbinlv closed 5 days ago

binbinlv commented 3 weeks ago

Is there an existing issue for this?

Environment

- Milvus version: master-20240920-6e430bd4
- Deployment mode(standalone or cluster):both
- MQ type(rocksmq, pulsar or kafka):    all
- SDK version(e.g. pymilvus v2.0.0rc2): 2.5.0rc80
- OS(Ubuntu or CentOS): 
- CPU/Memory: 
- GPU: 
- Others:

Current Behavior

Insert rows report error "undefined data type:Int64: invalid parameter" when insert without the default value field

RPC error: [insert_rows], <MilvusException: (code=1100, message=undefined data type:Int64: invalid parameter)>, <Time:{'RPC start': '2024-09-25 11:12:19.687618', 'RPC error': '2024-09-25 11:12:20.037542'}>
Traceback (most recent call last):
  File "./default_rows.py", line 24, in <module>
    collection.insert(data={"id": 4, "vector": [7,8,9]})
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/orm/collection.py", line 507, in insert
    return conn.insert_rows(
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 141, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 137, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 176, in handler
    return func(self, *args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 116, in handler
    raise e from e
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/decorators.py", line 86, in handler
    return func(*args, **kwargs)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/grpc_handler.py", line 496, in insert_rows
    check_status(resp.status)
  File "/Users/binbin/milvus_latest/lib/python3.8/site-packages/pymilvus/client/utils.py", line 63, in check_status
    raise MilvusException(status.code, status.reason, status.error_code)
pymilvus.exceptions.MilvusException: <MilvusException: (code=1100, message=undefined data type:Int64: invalid parameter)>

Expected Behavior

Insert rows successfully when insert without the default value field

Steps To Reproduce

from pymilvus import CollectionSchema, FieldSchema
from pymilvus import Collection
from pymilvus import connections
from pymilvus import DataType
from pymilvus import Partition
from pymilvus import utility
import json
import random

connections.connect()

dim = 3
schema = CollectionSchema(fields=[
    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=False),
    FieldSchema(name="vector", dtype=DataType.FLOAT_VECTOR, dim=3),
    FieldSchema(name="flat", dtype=DataType.INT64, default_value=999),
])

collection = Collection("test_binbin_123", schema=schema)

collection.insert(data={"id": 4, "vector": [7,8,9]})

Milvus Log

No response

Anything else?

No response

smellthemoon commented 1 week ago

related with https://github.com/milvus-io/pymilvus/pull/2275. pr merged, could you please check it? @binbinlv

smellthemoon commented 5 days ago

/assign @binbinlv

binbinlv commented 5 days ago

Verified and fixed:

pymilvus:2.5.0rc88 milvus: master-20241011-3fe0f829-amd64

results:

>>> dim = 3
>>> schema = CollectionSchema(fields=[
...     FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=False),
...     FieldSchema(name="vector", dtype=DataType.FLOAT_VECTOR, dim=3),
...     FieldSchema(name="flat", dtype=DataType.INT64, default_value=999),
... ])
>>>
>>>
>>> collection = Collection("test_binbin_12", schema=schema)
>>> collection.insert(data={"id": 4, "vector": [7,8,9]})
(insert count: 1, delete count: 0, upsert count: 0, timestamp: 453149575917862918, success count: 1, err count: 0
>>>
>>>
>>> index_param = {"index_type": "IVF_FLAT", "metric_type": "L2", "params": {"nlist": 100}}
>>> collection.create_index("vector", index_param, index_name="index_name_1")
Status(code=0, message=)
>>>
>>> collection.load()
>>> collection.query(expr="id>=0", output_fields=["flat", "vector"])
data: ["{'flat': 999, 'vector': [7.0, 8.0, 9.0], 'id': 4}"]