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

James Taylor commented on PHOENIX-1083:
---------------------------------------

Good, so that's the first part of the fix. Perf would suck though for the case 
we need it to be fast. So for the second part of the fix, we'll want to modify 
the check for fullyQualifiedColumnCount to take into account the previously 
filled key slots. If there are previously filled key slots, then we'll want to 
see if they're all point key ranges. If they're not then we still break. If 
they are, then we prepend those constants to the RVC constants and don't break.

Something like this:
{code}
            List<KeyRange> keyRanges = slot.getKeyRanges();
            if (fullyQualifiedColumnCount > 1) {
                if (      slot.getPKSpan() + pkPos == fullyQualifiedColumnCount
                    && !EVERYTHING_RANGES.equals(slot.getKeyRanges())
                    && isAllPointRanges(cnf)) {
                    schema = nBuckets == null ? SchemaUtil.VAR_BINARY_SCHEMA : 
                        SaltingUtil.VAR_BINARY_SALTED_SCHEMA;
                    if (pkPos > 0) {
                        // See ScanRanges.create() as a guide for doing this 
combining. You basically
                        // just need to prepend the keyRanges with the single 
KeyRange in each position
                        // from the cnf.
                        keyRanges = 
combinePriorPointRangesWithCurrentRanges(cnf, keyRanges);
                        // Reset current keyRanges collected so far back to an 
empty list,
                        // since they've been combined above. These keyRanges 
will be
                        // appended to the cnf below.
                        cnf = Lists.newArrayListWithExpectedSize(1);
                } else {
                    // Exit early, as if we have a RVC which doesn't span the 
entire primary constraint,
                    // we cannot optimize it.
                    // TODO: still optimize it if all columns before have 
constants specified
                    break;
                }
{code}

Want to give it a shot and implement the 
combinePriorPointRangesWithCurrentRanges(), [~kbuzsaki]? In essence, we should 
still be able to do our optimization of turning these RVC expression ANDed with 
these other PK columns into a point lookup.

> IN list of RVC combined with AND doesn't return expected rows
> -------------------------------------------------------------
>
>                 Key: PHOENIX-1083
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1083
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 3.0.0, 4.0.0, 5.0.0
>            Reporter: Samarth Jain
>            Assignee: James Taylor
>
> {code}
> CREATE TABLE in_test ( user VARCHAR, tenant_id VARCHAR(5) NOT 
> NULL,tenant_type_id VARCHAR(3) NOT NULL,  id INTEGER NOT NULL CONSTRAINT pk 
> PRIMARY KEY (tenant_id, tenant_type_id, id))
> upsert into in_test (tenant_id, tenant_type_id, id, user) values ('a', 'a', 
> 1, 'BonA')
> upsert into in_test (tenant_id, tenant_type_id, id, user) values ('a', 'a', 
> 2, 'BonB')
> select id from in_test WHERE tenant_id = 'a' and tenant_type_id = 'a' and 
> ((id, user) IN ((1, 'BonA'),(1, 'BonA')))
> Rows returned - none. Should have returned one row. 
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to