Skip to content

Support for Nullable Scalar Values #246

Description

@MrLoh

Moved this here from milvus-io/pymilvus#2495

Faulty Behavior

When I try to insert a row with nullable values into a collection in milvus lite, no error is returned but somehow the connection times out all of a sudden with StatusCode.UNAVAILABLE, failed to connect to all addresses; last error: UNKNOWN.

Expected Behavior

Milvus lite should support nullable scalar values or at least surface a proper error message

Steps/Code To Reproduce behavior

from pymilvus import DataType, MilvusClient

# setup client
database_uri = "./milvus.db"
client = MilvusClient(database_uri)
assert client is not None

# setup collection with nullable field
assert client.has_collection("test") is False
schema = client.create_schema(auto_id=False, enable_dynamic_field=True)
schema.add_field("id", DataType.INT64, is_primary=True)
schema.add_field("nullable", DataType.VARCHAR, max_length=256, nullable=True)
schema.add_field("vector", DataType.FLOAT_VECTOR, dim=2)
client.create_collection("test", schema=schema)
index_params = MilvusClient.prepare_index_params()
index_params.add_index(field_name="vector", index_name="test_vector", index_type="FLAT", metric_type="L2")
client.create_index("test", index_params=index_params)
client.load_collection("test")
assert client.has_collection("test") is True

# insert a row with no nullable values
client.insert("test", [{"id": 1, "nullable": "test", "vector": [0.0, 0.0]}])
assert client.query("test", output_fields=["count(*)"])[0]["count(*)"] == 1

# insert  a row with nullable values
client.insert("test", [{"id": 2, "nullable": None, "vector": [0.0, 0.0]}])

You will start seeing logs like this:

2024-12-20 16:19:20 [INFO] [describe_collection] retry:4, cost: 0.27s, reason: <_MultiThreadedRendezvous: StatusCode.UNAVAILABLE, failed to connect to all addresses; last error: UNKNOWN: unix:/var/folders/mw/h0vwcj5x08d0d7_8hhs01xlc0000gn/T/tmp54l8z0wy_milvus.db.sock: connect: Connection refused (61)>

Environment details

  • Hardware/Softward conditions: macOS, MacBook with M3 Max
  • Method of installation pymilvus
  • pymilvus v2.5.0 using milvus lite

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions