Skip to content

fix(optimizer): coerce numeric types in index column hints for int-float comparisons - #6174

Open
Tyagiquamar wants to merge 1 commit into
vesoft-inc:masterfrom
Tyagiquamar:fix/index-scan-int-float-equality
Open

Tyagiquamar wants to merge 1 commit into
vesoft-inc:masterfrom
Tyagiquamar:fix/index-scan-int-float-equality

Conversation

@Tyagiquamar

Copy link
Copy Markdown

What problem does this PR solve?

Fixes #6172.

When an INT property is compared to an integer-valued floating-point literal (e.g. 3000000000.0), queries executed via index scans on that property previously dropped matching rows. This occurred because OptimizerUtils::appendColHint used the float Value directly in IndexColumnHint without coercing it to the column definition schema type (INT64). In RocksDB storage, index keys for INT and DOUBLE use distinct encodings, causing index prefix seek misses.

What is changed and how does it work?

  1. Introduced SchemaUtil::coerceValue to safely convert representable integer floating-point literals to integer values for integer property types (and integer literals to float for float property types).
  2. Exposed OptimizerUtils::normalizeFilterValue to normalize filter expressions before creating column hints.
  3. Updated OptimizerUtils::appendColHint to validate and coerce candidate filter values to the column's expected data type for both prefix and range scans.
  4. Added test cases in IndexScanRuleTest for exact-integer float literals on int columns and int literals on double columns.
  5. Added test coverage in LookupValidatorTest.

Check List

Tests:

  • Unit test added in IndexScanRuleTest
  • Unit test added in LookupValidatorTest

@CLAassistant

CLAassistant commented Oct 1, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Equality on an INT property with a floating-point literal drops the matching row when a property index on that property is used (scan path returns it)

2 participants