Skip to content

fix: send the path of PATH_REPLACE field ops - #3902

Closed
zhengbuqian wants to merge 1 commit into
milvus-io:masterfrom
zhengbuqian:fix-field-op-path
Closed

zhengbuqian wants to merge 1 commit into
milvus-io:masterfrom
zhengbuqian:fix-field-op-path

Conversation

@zhengbuqian

@zhengbuqian zhengbuqian commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Prepare._apply_field_ops copied only field_name and op of each FieldPartialUpdateOp into the insert/upsert request and dropped path. A PATH_REPLACE op therefore reached the server without a path, so positional partial upsert (milvus-io/milvus#53016) could not be used from pymilvus.

Changes:

  • _apply_field_ops forwards path along with the field name and op.
  • New FieldOp.path_replace(path) factory, the form used in the PATH_REPLACE design (FieldOp.path_replace("[1]"), FieldOp.path_replace("[1][age]")). It rejects an empty or non-string path.
  • normalize_field_ops rejects a PATH_REPLACE op without a path (given as an enum, an int, or a proto message with no path) when the request is prepared, instead of sending it to the server.

Tests: new unit tests in tests/unit/prepare/test_partial_op.py cover the factory, path validation, and that the path reaches request.field_ops, both through _apply_field_ops directly and through batch_upsert_param. tests/unit passes locally (5498 passed, 1 skipped).

Prepare._apply_field_ops copied only field_name and op into the request, so a PATH_REPLACE op reached the server without its path and positional partial upsert could not work from pymilvus. Forward the path, add FieldOp.path_replace(path) as the documented way to build the op, and reject a PATH_REPLACE op without a path when the request is prepared.

Signed-off-by: Buqian Zheng <zhengbuqian@gmail.com>
@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zhengbuqian
To complete the pull request process, please assign longjiquan after the PR has been reviewed.
You can assign the PR to them by writing /assign @longjiquan in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mergify

mergify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.73%. Comparing base (e9e90a6) to head (b691b7f).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3902   +/-   ##
=======================================
  Coverage   94.73%   94.73%           
=======================================
  Files          81       81           
  Lines       17102    17109    +7     
=======================================
+ Hits        16201    16208    +7     
  Misses        901      901           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@XuanYang-cn XuanYang-cn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question about the documented Struct child replacement case.

"""Return a PATH_REPLACE op that replaces only the value at ``path``.

``path`` is relative to the field: ``"[1]"`` selects one Array or
Array-of-Struct element, ``"[1][age]"`` one child of a struct element,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the documented [1][age] case still be blocked by Struct operand serialization?

With a profile StructArray containing age and city, I reproduced this at the PR head through Prepare.row_upsert_param:

data = [{"id": 1, "profile": [{"age": 18}]}]
field_ops = {"profile": FieldOp.path_replace("[1][age]")}

Request preparation raises DataNotMatchException with missing required fields: {'city'}, because _validate_and_collect_struct_values still requires every schema child. Supplying city would conflict with the design requirement that a [index][child] operand contain exactly the named child.

This serializer restriction already exists on the base, but the new helper documents this use case. Do you consider this a gap that needs addressing here, with a row-upsert regression test, or is the required Struct operand support intentionally deferred?

@zhengbuqian

Copy link
Copy Markdown
Collaborator Author

/hold

need to redo this PR after #3882 merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants