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

Toshihiro Suzuki commented on PHOENIX-6098:
-------------------------------------------

{quote}
Do you have an example SQL query which would could be validated by hand? I can 
see how the code is broken given the context you've shared, but i'm not sure 
how I would write such a query to demonstrate that Phoenix-Hive does the 
correct thing after your change :)
{quote}
Thank you [~elserj]. Sorry, I should have shared that first.

The steps to reproduce this issue is as follows:

1. Create a table in Phoenix and upsert a row:
{code}
CREATE TABLE TEST (ID VARCHAR PRIMARY KEY, COL1 VARCHAR, COL2 VARCHAR, COL3 
VARCHAR);
UPSERT INTO TEST VALUES ('id', 'aaa', 'bbb', 'ccc');
{code}

2. Create an external table for the Phoenix table in Hive:
{code}
create external table test (
  id string,
  col1 string,
  col2 string,
  col3 string
)
STORED BY 'org.apache.phoenix.hive.PhoenixStorageHandler'
TBLPROPERTIES (
"phoenix.table.name" = "TEST",
"phoenix.zookeeper.quorum" = "<zookeeper quorum>",
"phoenix.zookeeper.znode.parent" = "<zookeeper znode parent>",
"phoenix.zookeeper.client.port" = "2181",
"phoenix.rowkeys" = "ID",
"phoenix.column.mapping" = "id:ID, col1:COL1, col2:COL2, col3:COL3"
);
{code}

3. Run a problematic query in Hive. It shouldn't return any results, but we can 
see it returns a row:
{code}
hive> select * from test where col1='aaa' and col2='bbb' and col3 like 'b%';
+----------+------------+------------+------------+
| test.id  | test.col1  | test.col2  | test.col3  |
+----------+------------+------------+------------+
| id       | aaa        | bbb        | ccc        |
+----------+------------+------------+------------+
{code}

As [[email protected]] mentioned in the PR, it looks like the issue is 
introduced after HIVE-11398:
https://github.com/apache/phoenix-connectors/pull/27#issuecomment-679291484

And I see HDP-3.1.5 has the same issue. Thanks.

> IndexPredicateAnalyzer wrongly handles pushdown predicates and residual 
> predicates
> ----------------------------------------------------------------------------------
>
>                 Key: PHOENIX-6098
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6098
>             Project: Phoenix
>          Issue Type: Bug
>          Components: hive-connector
>            Reporter: Toshihiro Suzuki
>            Assignee: Toshihiro Suzuki
>            Priority: Major
>
> Currently, the following code of IndexPredicateAnalyzer is assuming that 
> GenericUDFOPAnd always has 2 children nodes. I think this is wrong and it 
> leads wrong results:
> https://github.com/apache/phoenix-connectors/blob/5bd23ae2a0f70c3b3edf92a53780dafa643faf26/phoenix-hive/src/main/java/org/apache/phoenix/hive/ql/index/IndexPredicateAnalyzer.java#L346-L359



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to