You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by "ChenFangRong (JIRA)" <ji...@apache.org> on 2016/01/21 08:45:40 UTC

[jira] [Comment Edited] (PHOENIX-2617) query result not correct when pk is constraint and inlist condition in second position.

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

ChenFangRong edited comment on PHOENIX-2617 at 1/21/16 7:45 AM:
----------------------------------------------------------------

I solved it by modifying the code in AndOrExpression.java.
I test it, find out the sql query pass the test.
Happy ending~~ O(∩_∩)O~

the problem is that  the code in   public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {

            if (partialEvalState == null || !partialEvalState.get(i)) {
                // Call through to child evaluate method matching parent call to allow child to optimize
                // evaluate versus getValue code path.
                if (child.evaluate(tuple, ptr)) {
                    // Short circuit if we see our stop value
//                    if (Boolean.valueOf(stopValue).equals(PDataType.BOOLEAN.toObject(ptr, child.getDataType()))) {  --- -> problem code
                	//modify by ChenFangRong
                	 if (isStopValue((Boolean)PDataType.BOOLEAN.toObject(ptr, child.getDataType()))) {
                        return true;
                    } else if (partialEvalState != null) {
                        partialEvalState.set(i);
                    }
                } else {
                    isNull = true;
                }
            }

}


was (Author: fangrong.chen):
I solved it by modifying the code in AndOrExpression.java.
I test it and it pass the test.

the problem is that  the code in   public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) {

            if (partialEvalState == null || !partialEvalState.get(i)) {
                // Call through to child evaluate method matching parent call to allow child to optimize
                // evaluate versus getValue code path.
                if (child.evaluate(tuple, ptr)) {
                    // Short circuit if we see our stop value
//                    if (Boolean.valueOf(stopValue).equals(PDataType.BOOLEAN.toObject(ptr, child.getDataType()))) {  --- -> problem code
                	//modify by ChenFangRong
                	 if (isStopValue((Boolean)PDataType.BOOLEAN.toObject(ptr, child.getDataType()))) {
                        return true;
                    } else if (partialEvalState != null) {
                        partialEvalState.set(i);
                    }
                } else {
                    isNull = true;
                }
            }

}

> query result not correct when pk is constraint and inlist condition in second position.
> ---------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-2617
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2617
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 3.1.0
>         Environment: CentOS
>            Reporter: ChenFangRong
>            Assignee: James Taylor
>              Labels: easyfix
>
> create Table sql,
> CREATE TABLE bugTable ( name varchar, address varchar,company varchar, interest varchar CONSTRAINT pk PRIMARY KEY (name,address,company) );
> upsert the value,the table and its value is now as below:
> upsert value sql,
> upsert into bugTable values ('A1','B1','C1','D1');
> upsert into bugTable (name,company,interest) values ('A2','C2','D2');
> upsert into bugTable values ('A3','B3','C3','D3');
> name address company interest
> A1       B1           C1           D1
> A2       null          C2           D2
> A3       B3           C3           D3
> if you use the sql to query:
> select * from bugTable where address in('B1','B3') and interest='D2';
> the query result is :
> name  address  company  interest
> A2        null         C2                D2
> the result is supposed to be null.
> but the fact is it has a result,phoenix does not filter the column where the value of address is null.



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