[ 
https://issues.apache.org/jira/browse/PHOENIX-1535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14250704#comment-14250704
 ] 

Maryann Xue commented on PHOENIX-1535:
--------------------------------------

[~rajeshbabu] It turned out to be much more complicated than what I had 
described. [~joycelau1]'s case was a special one for which a simple fix would 
be enough.

I am attaching a patch containing part of the fix. In ScanRegionObserver, I 
switched the sequence of constructing the RegionScanners, making the "wrapped 
scanner" the inner scanner of HashJoinRegionScanner, since local index 
projection should happen before hash-join. I think similar fixes should be 
applied with GroupedAggregateRegionObserver and 
UngroupedAggregateRegionObserver, but things are more complicated there: the 
HashJoinRegionScanner should sit in between the local index projection and the 
grouped/ungrouped aggregate operation, unlike now it happens before the two 
operations.

I assume though, having a "wrapped scanner" for local index projection in 
GroupedAggregateRegionObserver and UngroupedAggregateRegionObserver the same 
way as in ScanRegionObserver would probably make things easier and the code 
more unified. Not sure if we can do this or if this would raise any other 
issues?

[~joycelau1], you can move on with this patch which fixes your specific test 
case.

> Secondary local index casues Undefined column error with queries involving 
> joins
> --------------------------------------------------------------------------------
>
>                 Key: PHOENIX-1535
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1535
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.2
>         Environment: HBase 0.98.6; CDH-5.2.0-1.cdh5.2.0.p0.36
>            Reporter: Joyce Lau
>
> Create 2 tables with a local index
> create table tab1 (col1 bigint, col2 bigint, col3 bigint, constraint pk_tab1 
> primary key (col1));
> create table tab2 (col1 bigint, col2 bigint, col3 bigint, constraint pk_tab1 
> primary key (col1));
> create local index ind_tab1 on tab1(col2);
> Executing a query with a condition on the local index column and select a 
> column not in the index results in an error:
> explain
> select tab1.col3
> from tab1 join tab2 on tab1.col1 = tab2.col1
> where tab1.col2 = 1
> =======
> Error: ERROR 504 (42703): Undefined column. columnName=0:COL3
> SQLState:  42703
> ErrorCode: 504
> =======
> Select * is ok:
> explain select tab1.* from tab1 where tab1.col2 = 1
> If I drop the local index, the first query runs successfully.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to