Fix dimension type comparison in Milvus vector field validation
• Convert dimensions to int for comparison • Handle string vs int type mismatches
This commit is contained in:
parent
06533fdb58
commit
0fa9a2eee3
1 changed files with 26 additions and 3 deletions
|
|
@ -462,14 +462,37 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|||
if type_name in ["FloatVector", "FLOAT_VECTOR"]:
|
||||
existing_dimension = field.get("params", {}).get("dim")
|
||||
|
||||
if existing_dimension != current_dimension:
|
||||
# Convert both to int for comparison to handle type mismatches
|
||||
# (Milvus API may return string "1024" vs int 1024)
|
||||
try:
|
||||
existing_dim_int = (
|
||||
int(existing_dimension)
|
||||
if existing_dimension is not None
|
||||
else None
|
||||
)
|
||||
current_dim_int = (
|
||||
int(current_dimension)
|
||||
if current_dimension is not None
|
||||
else None
|
||||
)
|
||||
except (TypeError, ValueError) as e:
|
||||
logger.error(
|
||||
f"[{self.workspace}] Failed to parse dimensions: existing={existing_dimension} (type={type(existing_dimension)}), "
|
||||
f"current={current_dimension} (type={type(current_dimension)}), error={e}"
|
||||
)
|
||||
raise ValueError(
|
||||
f"Invalid dimension values for collection '{self.final_namespace}': "
|
||||
f"existing={existing_dimension}, current={current_dimension}"
|
||||
) from e
|
||||
|
||||
if existing_dim_int != current_dim_int:
|
||||
raise ValueError(
|
||||
f"Vector dimension mismatch for collection '{self.final_namespace}': "
|
||||
f"existing={existing_dimension}, current={current_dimension}"
|
||||
f"existing={existing_dim_int}, current={current_dim_int}"
|
||||
)
|
||||
|
||||
logger.debug(
|
||||
f"[{self.workspace}] Vector dimension check passed: {current_dimension}"
|
||||
f"[{self.workspace}] Vector dimension check passed: {current_dim_int}"
|
||||
)
|
||||
return
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue