Skip to content

fix(server): avoid extracting text range filters#3034

Open
LegendPei wants to merge 12 commits into
apache:masterfrom
LegendPei:fix/fix-text-range-filter
Open

fix(server): avoid extracting text range filters#3034
LegendPei wants to merge 12 commits into
apache:masterfrom
LegendPei:fix/fix-text-range-filter

Conversation

@LegendPei
Copy link
Copy Markdown

@LegendPei LegendPei commented May 21, 2026

Purpose of the PR

This PR fixes the query-planning path exposed by #2935.

For top-level traversals like g.V().has("vp4", P.lt("")).repeat(...).count(),
HugeGraph may extract the text range predicate into a backend query. However,
range predicates on text properties should not be planned as backend range
index queries. This can make the direct traversal fail while an equivalent
match() traversal returns normally.

This change keeps such text range predicates in the traversal layer instead of
pushing them down to the backend query, making the direct traversal consistent
with the equivalent match() form.

Main Changes

  • Avoid extracting Text property predicates with gt/gte/lt/lte into
    HugeGraphStep / HugeVertexStep backend queries.
  • Preserve normal extraction for system properties and non-text property
    predicates.
  • Add a regression test for the reported traversal shape:
    has("vp4", P.lt("")).repeat(__.out("el2")).emit().times(1).count().
  • Verify that the direct traversal returns the same result as the equivalent
    match() traversal.

Verifying these changes

  • 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 -pl hugegraph-server/hugegraph-test -am -P core-test,memory -Dtest=CountStrategyCoreTest#testRepeatAfterTextRangeFilterWithEmptyResult -DfailIfNoTests=false "-Drat.skip=true" "-Dcheckstyle.skip=true" test
    • mvn -pl hugegraph-server/hugegraph-test -am -P core-test,rocksdb -Dtest=CountStrategyCoreTest#testRepeatAfterTextRangeFilterWithEmptyResult -DfailIfNoTests=false "-Drat.skip=true" "-Dcheckstyle.skip=true" test

Does this PR potentially affect the following parts?

Documentation Status

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

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels May 21, 2026
@imbajin imbajin requested a review from Copilot May 21, 2026 06:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a traversal query-planning bug where range predicates (gt/gte/lt/lte) on Text properties were being extracted/pushed down into backend queries, leading to incorrect behavior (and the exception reported in #2935). The change keeps these text range predicates in the traversal layer while adding a regression test to ensure direct traversals behave consistently with equivalent match() traversals.

Changes:

  • Prevent extraction of HasStep containers when they include range comparisons on Text properties.
  • Keep existing extraction behavior for system properties and non-text property predicates (intended).
  • Add a regression test reproducing the traversal shape from #2935 and asserting consistent results between direct and match() forms.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/TraversalUtil.java Adds a guard to stop extracting HasContainers with text range predicates into backend query steps.
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/core/CountStrategyCoreTest.java Adds a regression test covering a text range filter followed by repeat(...).emit().times(1).count().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

LegendPei added 2 commits May 21, 2026 14:56
…fix/fix-text-range-filter

# Conflicts:
#	hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/TraversalUtil.java
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.25%. Comparing base (454dd3d) to head (a361614).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@              Coverage Diff              @@
##             master    #3034       +/-   ##
=============================================
+ Coverage     35.94%   93.25%   +57.31%     
+ Complexity      338       65      -273     
=============================================
  Files           803        9      -794     
  Lines         68053      267    -67786     
  Branches       8907       22     -8885     
=============================================
- Hits          24460      249    -24211     
+ Misses        40968        8    -40960     
+ Partials       2625       10     -2615     

☔ View full report in Codecov by Sentry.
📢 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.

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 21, 2026
@LegendPei LegendPei requested a review from Copilot May 21, 2026 07:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

@LegendPei LegendPei requested a review from Copilot May 21, 2026 11:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

@LegendPei LegendPei requested a review from Copilot May 21, 2026 12:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

@LegendPei LegendPei requested a review from Copilot May 21, 2026 12:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

@LegendPei LegendPei requested a review from Copilot May 21, 2026 13:15
Copy link
Copy Markdown
Member

@imbajin imbajin left a comment

Choose a reason for hiding this comment

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

The original correctness fix is clear, but the latest version now broadens the PR into a more aggressive HasStep split-and-remove optimization. I left one scope/risk comment suggesting we keep this PR on the minimal safe path and move the broader optimization to a follow-up.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

@LegendPei LegendPei requested a review from imbajin May 23, 2026 09:03
Copy link
Copy Markdown
Member

@imbajin imbajin left a comment

Choose a reason for hiding this comment

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

The current patch looks scoped back to the safer minimal fix. I left three non-blocking test-coverage suggestions to better guard the text-range extraction behavior and related fallback paths.

@LegendPei LegendPei requested a review from imbajin May 24, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Unexpected ArrayIndexOutOfBoundsException for filter-step and repeat()-step

3 participants