fix: allow null auto_id primary column in DataFrame insert#3673
Conversation
c50bc56 to
3373c79
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3673 +/- ##
==========================================
+ Coverage 93.93% 94.02% +0.08%
==========================================
Files 72 72
Lines 15541 15567 +26
==========================================
+ Hits 14599 14637 +38
+ Misses 942 930 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Additional trigger context for reviewers: This bug is not a broad DataFrame insert failure. It requires four conditions to line up:
In that case, columns = list(data.columns)
columns.remove(schema.primary_field)A realistic way to hit this is an ETL/DataFrame workflow where the source table or CSV/Parquet schema still has an |
3373c79 to
63a64ce
Compare
Signed-off-by: VectorPeak <73048950+VectorPeak@users.noreply.github.com> Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> Signed-off-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
63a64ce to
18a0389
Compare
|
Tick the box to add this pull request to the merge queue (same as
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: VectorPeak, XuanYang-cn The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
✅ Backport Created (cc @XuanYang-cn) |
|
✅ Backport Created (cc @XuanYang-cn) |
…sert (#3673) (#3678) Backport of #3673 to `3.0`. Signed-off-by: VectorPeak <73048950+VectorPeak@users.noreply.github.com> Signed-off-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> Signed-off-by: pymilvus-bot <pymilvus-bot@users.noreply.github.com> Co-authored-by: VectorPeak <garrufariw@gmail.com> Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
…sert (#3673) (#3677) Backport of #3673 to `2.6`. Signed-off-by: VectorPeak <73048950+VectorPeak@users.noreply.github.com> Signed-off-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com> Signed-off-by: pymilvus-bot <pymilvus-bot@users.noreply.github.com> Co-authored-by: VectorPeak <garrufariw@gmail.com> Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
This PR fixes a DataFrame insert validation crash when an auto_id primary key column is present but contains only null values.
What Problem This Solves
check_insert_schema()already treats an all-null auto_id primary key column as "no primary key values were provided" and tries to remove that column before validating the remaining DataFrame fields.The current code builds a list of DataFrame column labels, but then attempts to remove the
FieldSchemaobject itself:Since
data.columnscontains column names, notFieldSchemaobjects, this raises:A minimal trigger is an auto_id schema with a DataFrame that keeps the primary key column but leaves it entirely null:
Change
Remove the primary key column by its field name instead of by the
FieldSchemaobject:This keeps the existing behavior unchanged for non-null auto_id primary key values: if users explicitly provide primary key data,
check_insert_schema()still raisesDataNotMatchException.Evidence
Before this fix,
check_insert_schema()crashes before it can validate the remaining DataFrame fields:After this fix:
DataNotMatchException.Possible call chain / impact
This PR only changes the column removal path for all-null auto_id primary key columns in DataFrame insert validation. It does not change list-based inserts, row-based inserts, upsert validation, or the existing rejection of non-null auto_id primary key values.
Testing
uv run --python 3.11 --group dev pytest tests/unit/orm/test_schema.py::TestCheckInsertSchema -quv run --python 3.11 --group dev pytest tests/unit/orm/test_prepare.py -k auto_id -quv run --python 3.11 --group dev black --check pymilvus/orm/schema.py tests/unit/orm/test_schema.pyuv run --python 3.11 --group dev ruff check pymilvus/orm/schema.py tests/unit/orm/test_schema.pygit diff --check -- pymilvus/orm/schema.py tests/unit/orm/test_schema.py