TheNamesRai opened a new pull request, #2298:
URL: https://github.com/apache/phoenix/pull/2298

   PHOENIX-6644 Fix ResultSet.getString(columnName) for view index queries with 
constant columns
   
   Design doc - 
[link](https://docs.google.com/document/d/18eN6VdIYfquwTXtmGUBCOMKIXnr5oaj7BrMjF-srYUs/edit?tab=t.0)
   
   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. This violates JDBC specification.
   
   Root cause: IndexStatementRewriter converts view constants to literals during
   optimization (ColumnParseNode("status") → LiteralParseNode("ACTIVE")), 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. This preserves both 
query
   optimization benefits and JDBC-compliant column name access.
   
   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)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to