milvus
milvus copied to clipboard
fix: Handle default values correctly during compaction for added fields
Related to #45543
When a field with a default value is added to a collection, the default value becomes null after compaction instead of retaining the expected default value.
Root Cause
The appendValueAt function in internal/storage/arrow_util.go incorrectly checked if the entire arrow.Array was nil before handling default values. This meant that default values were only applied when the array itself was nil, not when individual field values were null (which is the correct condition).
Changes
-
Early nil check: Added a guard at the function entry to detect nil arrow.Array and return an error immediately, as this is an unexpected condition that should not occur during normal operation.
-
Refactored default value handling: Removed the per-type nil array checks and moved default value logic to handle individual null values within the array (when
IsNull(idx)returns true). -
Applied to all types: Updated the logic consistently across all builder types:
- BooleanBuilder
- Int8Builder, Int16Builder, Int32Builder, Int64Builder
- Float32Builder
- StringBuilder
- BinaryBuilder (added default value support for internal $meta json)
- ListBuilder (removed unnecessary nil check)
[ci-v2-notice] Notice: We are gradually rolling out the new ci-v2 system.
- Legacy CI jobs remain unaffected, you can just ignore ci-v2 if you don't want to run it.
- Additional "ci-v2/*" checkers will run for this PR to ensure the new ci-v2 system is working as expected.
- For tests that exist in both v1 and v2, passing in either system is considered PASS.
To rerun ci-v2 checks, comment with:
- /ci-rerun-code-check // for ci-v2/code-check
- /ci-rerun-build // for ci-v2/build
- /ci-rerun-ut-integration // for ci-v2/ut-integration
- /ci-rerun-ut-go // for ci-v2/ut-go
- /ci-rerun-ut-cpp // for ci-v2/ut-cpp
- /ci-rerun-ut // for all ci-v2/ut-integration, ci-v2/ut-go, ci-v2/ut-cpp
- /ci-rerun-e2e-arm // for ci-v2/e2e-arm
If you have any questions or requests, please contact @zhikunyao.
Codecov Report
:x: Patch coverage is 83.33333% with 6 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 76.48%. Comparing base (96d0e78) to head (dd78d05).
:warning: Report is 1 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| internal/storage/arrow_util.go | 83.33% | 6 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #45572 +/- ##
==========================================
- Coverage 76.55% 76.48% -0.07%
==========================================
Files 1875 1875
Lines 291983 291953 -30
==========================================
- Hits 223531 223307 -224
- Misses 61073 61237 +164
- Partials 7379 7409 +30
| Components | Coverage Δ | |
|---|---|---|
| Client | 78.17% <ø> (ø) |
|
| Core | 83.18% <ø> (ø) |
|
| Go | 74.59% <83.33%> (-0.11%) |
:arrow_down: |
| Files with missing lines | Coverage Δ | |
|---|---|---|
| internal/storage/arrow_util.go | 72.55% <83.33%> (+11.46%) |
:arrow_up: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
/ci-rerun-ut-go
@congqixia cpu-e2e job failed, comment /run-cpu-e2e can trigger the job again.
/run-cpu-e2e
/ci-rerun-ut-integration
@congqixia cpu-e2e job failed, comment /run-cpu-e2e can trigger the job again.
/ci-rerun-ut-go
/ci-rerun-ut-go
/ci-rerun-ut-go
/ci-rerun-ut-go
/lgtm /approve
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: congqixia, tedxu
The full list of commands accepted by this bot can be found here.
The pull request process is described here
- ~~internal/storage/OWNERS~~ [congqixia,tedxu]
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment