-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Primary key field is lost during upsert #399
Comments
Ok, I will test it and make a fix soon. |
…mic row see milvus-io#399 Signed-off-by: Frank <25704248+rakuzen25@users.noreply.github.com>
Hi @shanghaikid - thank you for the fixes. Are there any plans on when the next version will be published? |
tomorrow:) |
New version released |
Describe the bug:
When both auto ID and dynamic field are turned on in the collection, the primary key gets moved to the dynamic
$meta
field or lost along the way, which creates an issue for the upsert (and insert?) operation.Steps to reproduce:
Do something like:
Output:
I've tried to debug the source code a little. First, a field is not added to the field map if it's a primary key and auto ID is on:
milvus-sdk-node/milvus/grpc/Data.ts
Lines 149 to 155 in 1750962
Then, I observed that the primary key gets dropped in
rowData
and added as a dynamic field (with a catch explained later):milvus-sdk-node/milvus/grpc/Data.ts
Lines 183 to 193 in 1750962
Stepping into
buildDynamicRow
:milvus-sdk-node/milvus/utils/Format.ts
Lines 444 to 468 in 1750962
Here I observed two issues. First, as described by the issue itself,
langchain_primaryid
is not present in the final fields passed to the gRPC client. Second, I noticed that one of the other runs gave me this output:This is because
$meta
is registered in the field map:milvus-sdk-node/milvus/grpc/Data.ts
Lines 171 to 181 in 1750962
Hence, when
key
is$meta
,row[key] = originRow[key]
in L460 will be executed, which overwrites the existing state ofrow.$meta
. In other words, if present in the original data, the$meta
key can overwrite itself in the loop. Since the order of the loop does not seem to be guaranteed, the primary key can be completely lost if it's processed before the$meta
key.For this second issue, I am planning to open a PR to check for
key === dynamicFieldName
in case a user does something like the example, where they directly modify data fromclient.query
(which includes the$meta
field). But for the first issue, I think it might be related to the design of the!v.is_primary_key || !v.autoID
condition.Milvus-node-sdk version:
@zilliz/milvus2-sdk-node 2.5.2
Milvus version:
Zilliz Cloud Vector Database(Compatible with Milvus 2.4)
The text was updated successfully, but these errors were encountered: