Skip to content

Conversation

TheNamesRai
Copy link

@TheNamesRai TheNamesRai commented Oct 10, 2025

PHOENIX-6644 Fix ResultSet.getString(columnName) for view index queries with constant columns

Design doc - link

When a view has constant columns in its WHERE clause (e.g., WHERE status='ACTIVE')
and an index is used, ResultSet.getString("status") throws ColumnNotFoundException
while getString(1) works.

Root cause: IndexStatementRewriter converts view constants to literals during
optimization, losing the original column name from RowProjector.reverseIndex.

Solution: Merge column name mappings from the original data plan projector into
the optimized index plan projector in QueryCompiler.

Changes:

  • RowProjector: Added constructor accepting additionalNameMappings parameter
    for immutable merging during construction
  • RowProjector: Implemented mergeColumnNameMappings() to build and merge
    additional column name mappings without post-construction mutation
  • QueryCompiler: Integrate projector merging after ProjectionCompiler in
    compileSingleFlatQuery() when dataPlans contains the optimized TableRef
  • ViewIndexColumnNameGetterIT: New comprehensive test suite (6 tests covering
    basic scenario, multiple constants, wildcards, PreparedStatement, subqueries)
  • GlobalIndexOptimizationIT: Uncommented previously failing assertion

Testing: 6 new tests + existing suite (39 tests pass: ViewIndexIT, GlobalIndexOptimizationIT)

@TheNamesRai TheNamesRai force-pushed the ViewIndexRowProjector branch from b951db4 to 9ee4c90 Compare October 10, 2025 09:27
@TheNamesRai
Copy link
Author

TheNamesRai commented Oct 21, 2025

All unit tests are passing in my local

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.

1 participant