Skip to content

fix(core): normalize boolean range predicates in Gremlin filters#2991

Open
contrueCT wants to merge 5 commits intoapache:masterfrom
contrueCT:task/fix-2934
Open

fix(core): normalize boolean range predicates in Gremlin filters#2991
contrueCT wants to merge 5 commits intoapache:masterfrom
contrueCT:task/fix-2934

Conversation

@contrueCT
Copy link
Copy Markdown
Contributor

Purpose of the PR

This PR fixes HugeGraph's inconsistent handling of boolean range predicates and unifies the internal ordering semantics as false < true. Previously, filter-step queries such as where(__.has("xxx", P.lt(true))) were pushed down through HugeGraph's condition/query pipeline and incorrectly treated as numeric-style range conditions, while equivalent match() queries could still return results normally. As a result, semantically equivalent traversals behaved differently.

Main Changes

The fix has two parts. First, boolean support is added to backend condition comparison and range-flattening logic so gt/gte/lt/lte can be evaluated consistently. Second, runtime Gremlin boolean range predicates are normalized into equivalent eq/in/empty conditions before query planning, so they are no longer misclassified as ordinary numeric range queries that require a range index. This preserves the intended boolean ordering semantics while making has(), where(), and match() behave consistently for boolean range predicates.

Verifying these changes

Regression coverage was also added for:

  • low-level boolean lt/lte/gt/gte comparison semantics
  • boolean range merge and conflicting-range flattening
  • end-to-end consistency across has(), where(), and match()
  • empty-result edge cases such as lt(false) and gt(true)
  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • mvn -Drat.skip=true -P core-test,memory -pl hugegraph-server/hugegraph-test,hugegraph-struct -am -DfailIfNoTests=false '-Dtest=ConditionTest,ConditionQueryFlattenTest,EdgeCoreTest#testQueryEdgeByBooleanRangePredicate' clean test

Does this PR potentially affect the following parts?

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working gremlin TinkerPop gremlin tests Add or improve test cases labels Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working gremlin TinkerPop gremlin size:L This PR changes 100-499 lines, ignoring generated files. tests Add or improve test cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Unexpected NumberFormatException for filter-step

1 participant