fix(query): clarify condition resolution semantics for label queries#2994
fix(query): clarify condition resolution semantics for label queries#2994contrueCT wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2994 +/- ##
============================================
- Coverage 35.94% 1.56% -34.39%
+ Complexity 338 43 -295
============================================
Files 803 781 -22
Lines 68053 65586 -2467
Branches 8907 8469 -438
============================================
- Hits 24465 1026 -23439
- Misses 40967 64474 +23507
+ Partials 2621 86 -2535 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add explicit condition resolution APIs to ConditionQuery while preserving the legacy condition() behavior. Introduce containsCondition(Object), conditionValues(Object), and conditionValue(Object) so callers can distinguish missing, empty, unique, and multi-value results without overloading null semantics. Migrate LABEL-specific consumers in graph/index transactions, serializers, traversers, and stores to use the new APIs for unique-label resolution and conservative fallback behavior. Extend QueryTest and VertexCoreTest to cover absent, conflicting, and multi-value label conditions as well as collectMatchedIndexes() behavior for multi-label and conflicting label queries.
4c42786 to
cc9af24
Compare
There was a problem hiding this comment.
I found one correctness issue in the latest revision. The CI failures were posted separately as a PR-level reminder.
CI/status checks are failing on the latest head (cc9af24929e42af1c90e1f55f3e60adc351e0318). Could you check the failed jobs before the next review round?
Failed checks include:
build-server (memory, 11): https://github.com/apache/hugegraph/actions/runs/26448131941/job/77861497015
| List<? extends SchemaLabel> schemaLabels; | ||
| if (label != null) { | ||
| // Query has LABEL condition | ||
| if (hasLabel && labels.isEmpty()) { |
There was a problem hiding this comment.
containsCondition(HugeKeys.LABEL) returns true for any top-level LABEL relation, but conditionValues(HugeKeys.LABEL) only collects EQ/IN relations. For a query such as has(T.label, P.neq("author")).has("name", ...), TraversalUtil can produce a Condition.neq(HugeKeys.LABEL, ...); hasLabel becomes true, labels is empty, and this branch returns no matched indexes immediately.
Before this change, query.condition(HugeKeys.LABEL) would not resolve a single label for this shape, so collectMatchedIndexes() fell back to scanning candidate schema labels and let the remaining conditions filter results. With the new branch, indexed user-property queries combined with a non-EQ/IN label predicate can incorrectly fail with no matched index / no result path.
Please distinguish "LABEL EQ/IN conditions resolved to an empty intersection" from "LABEL exists but has no EQ/IN-resolvable value". The latter should keep the conservative fallback, or add regression coverage for a label neq / non-EQ label predicate combined with an indexed user property.
cc9af24 to
2e82f83
Compare
Purpose of the PR
ConditionQuery.condition()currently mixes several different meanings in one API, including:This PR keeps the legacy
condition()behavior unchanged, adds explicit condition-resolution APIs, and migrates the high-riskLABELcall sites to use the clearer semantics.Main Changes
ConditionQuerycontainsCondition(Object key)conditionValues(Object key)conditionValue(Object key)condition()method backward-compatibleLABEL-related high-risk callers to the new APIs in:LABELlegacy usages in this first stepVerifying these changes
Added and extended regression coverage for the new semantics:
QueryTest#testConditionWithoutLabelQueryTest#testConditionWithEqAndInQueryTest#testConditionWithSingleInValuesQueryTest#testConditionWithConflictingEqAndInQueryTest#testConditionWithMultipleMatchedInValuesAdded a targeted regression for the label-index fallback path:
VertexCoreTest#testCollectMatchedIndexesByJointLabelsWithIndexedPropertiesThis test verifies:
Existing label-query regressions were also rechecked to ensure no behavior regression:
EdgeCoreTest#testQueryInEdgesOfVertexByLabelsEdgeCoreTest#testQueryInEdgesOfVertexByConflictingLabelsEdgeCoreTest#testQueryInEdgesOfVertexBySortkeyVertexCoreTest#testQueryByJointLabelsDoes this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - DoneDoc - No Need