Skip to content

Commit

Permalink
fix: row based insert/upsert when there is Function in schema (#2298)
Browse files Browse the repository at this point in the history
also fix schema comparison of tokenizer_params: tokenizer_params
returned by the server is in string format, while the user may provide
it in dict format. But this fix is not perfect and will likely fail when
tokenizer_params become more complicate due to possible json key
reordering.

@XuanYang-cn any idea? tracking this issue in
#2299

Signed-off-by: Buqian Zheng <[email protected]>
  • Loading branch information
zhengbuqian authored Oct 15, 2024
1 parent 76de0ab commit d5a3e59
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pymilvus/client/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,11 @@ def _parse_row_request(
entity_helper.pack_field_value_to_field_data(v, field_data, field_info)
for field in fields_info:
key = field["name"]
if key in entity or field.get("auto_id", False):
if (
key in entity
or field.get("auto_id", False)
or field.get("is_function_output", False)
):
continue

field_info, field_data = field_info_map[key], fields_data[key]
Expand Down Expand Up @@ -515,7 +519,7 @@ def _parse_upsert_row_request(
entity_helper.pack_field_value_to_field_data(v, field_data, field_info)
for field in fields_info:
key = field["name"]
if key in entity:
if key in entity or field.get("is_function_output", False):
continue

field_info, field_data = field_info_map[key], fields_data[key]
Expand Down
7 changes: 7 additions & 0 deletions pymilvus/orm/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# the License.

import copy
import json
from typing import Any, Dict, List, Optional, Union

import pandas as pd
Expand Down Expand Up @@ -450,6 +451,12 @@ def _parse_type_params(self):
if self._kwargs[k].lower() == "false":
self._type_params[k] = False
continue
if k == "tokenizer_params":
# TODO: a more complicate json may be reordered which
# can still cause server_schema == schema to be False.
# need a better approach.
self._type_params[k] = json.loads(self._kwargs[k])
continue
self._type_params[k] = self._kwargs[k]

@classmethod
Expand Down

0 comments on commit d5a3e59

Please sign in to comment.