You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@phoenix.apache.org by Gašper Metelko <ga...@salviol.com> on 2015/09/25 15:52:53 UTC

Error with union all and a hint

Hi

I have a problem with executing a UNION ALL statment with added hints. I need the hints to be able to use the index. For example:

explain SELECT /*+ INDEX(table1 INDEX_TABLE1_COL) */ col1, col2 FROM table1 WHERE col1='123' UNION ALL SELECT /*+ INDEX(table2 INDEX_TABLE2_COL) */ col1, col2 FROM table2 WHERE col1='123';

I get an error:
java.lang.NullPointerException
        at java.util.ArrayList.addAll(ArrayList.java:559)
        at org.apache.phoenix.iterate.UnionResultIterators.<init>(UnionResultIterators.java:51)
        at org.apache.phoenix.execute.UnionPlan.iterator(UnionPlan.java:131)
        at org.apache.phoenix.execute.UnionPlan.iterator(UnionPlan.java:127)
        at org.apache.phoenix.execute.UnionPlan.getExplainPlan(UnionPlan.java:150)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:424)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:403)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:246)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:241)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:240)
        at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1250)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)

I am using phoenix-4.4.0-HBase-1.1, the tables and indexes are as follows. I will greatly appriciate any help.

Regards, Gasper

CREATE TABLE table1 (
  id BIGINT,
  col1 VARCHAR,
  col2 VARCHAR,
  CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true;

CREATE TABLE table2 (
  id BIGINT,
  col1 VARCHAR,
  col2 VARCHAR,
  CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true;

CREATE INDEX INDEX_TABLE1_COL ON table1 (col1);

CREATE INDEX INDEX_TABLE2_COL ON table2 (col1);



Re: Error with union all and a hint

Posted by Alicia Shu <as...@hortonworks.com>.
Great. Thanks.

Alicia

From: Gašper Metelko <ga...@salviol.com>>
Reply-To: "user@phoenix.apache.org<ma...@phoenix.apache.org>" <us...@phoenix.apache.org>>
Date: Tuesday, September 29, 2015 at 2:50 AM
To: "user@phoenix.apache.org<ma...@phoenix.apache.org>" <us...@phoenix.apache.org>>
Subject: RE: Error with union all and a hint

I have created the jira PHOENIX-2295<https://issues.apache.org/jira/browse/PHOENIX-2295>.

Running the query without the hint, executes the statment with a full table scan:

0: jdbc:phoenix:localhost> explain SELECT  col1, col2 FROM table1 WHERE col1='123';
+------------------------------------------+
|                   PLAN                   |
+------------------------------------------+
| CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER TABLE1 |
|     SERVER FILTER BY COL1 = '123'        |
+------------------------------------------+

Running the query wit the hint:

0: jdbc:phoenix:localhost> explain SELECT /*+ INDEX(table1 INDEX_TABLE1_COL) */ col1, col2 FROM table1 WHERE col1='123';
+------------------------------------------+
|                   PLAN                   |
+------------------------------------------+
| CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER TABLE1 |
|     SKIP-SCAN-JOIN TABLE 0               |
|         CLIENT 1-CHUNK PARALLEL 1-WAY RANGE SCAN OVER INDEX_TABLE1_COL ['123'] |
|             SERVER FILTER BY FIRST KEY ONLY |
|     DYNAMIC SERVER FILTER BY "TABLE1.ID" IN ($72.$74) |
+------------------------------------------+

Regards, Gasper

From: Alicia Shu [mailto:ashu@hortonworks.com]
Sent: Tuesday, September 29, 2015 9:24 AM
To: user@phoenix.apache.org<ma...@phoenix.apache.org>
Subject: Re: Error with union all and a hint

By default if there is an index defined for a table, the index will be used if the plan with the index is better. Please file a Jira for the NPE.

Thanks,
Alicia

From: Gašper Metelko <ga...@salviol.com>>
Reply-To: "user@phoenix.apache.org<ma...@phoenix.apache.org>" <us...@phoenix.apache.org>>
Date: Friday, September 25, 2015 at 6:52 AM
To: "user@phoenix.apache.org<ma...@phoenix.apache.org>" <us...@phoenix.apache.org>>
Subject: Error with union all and a hint

Hi

I have a problem with executing a UNION ALL statment with added hints. I need the hints to be able to use the index. For example:

explain SELECT /*+ INDEX(table1 INDEX_TABLE1_COL) */ col1, col2 FROM table1 WHERE col1='123' UNION ALL SELECT /*+ INDEX(table2 INDEX_TABLE2_COL) */ col1, col2 FROM table2 WHERE col1='123';

I get an error:
java.lang.NullPointerException
        at java.util.ArrayList.addAll(ArrayList.java:559)
        at org.apache.phoenix.iterate.UnionResultIterators.<init>(UnionResultIterators.java:51)
        at org.apache.phoenix.execute.UnionPlan.iterator(UnionPlan.java:131)
        at org.apache.phoenix.execute.UnionPlan.iterator(UnionPlan.java:127)
        at org.apache.phoenix.execute.UnionPlan.getExplainPlan(UnionPlan.java:150)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:424)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:403)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:246)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:241)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:240)
        at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1250)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)

I am using phoenix-4.4.0-HBase-1.1, the tables and indexes are as follows. I will greatly appriciate any help.

Regards, Gasper

CREATE TABLE table1 (
  id BIGINT,
  col1 VARCHAR,
  col2 VARCHAR,
  CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true;

CREATE TABLE table2 (
  id BIGINT,
  col1 VARCHAR,
  col2 VARCHAR,
  CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true;

CREATE INDEX INDEX_TABLE1_COL ON table1 (col1);

CREATE INDEX INDEX_TABLE2_COL ON table2 (col1);



RE: Error with union all and a hint

Posted by Gašper Metelko <ga...@salviol.com>.
I have created the jira PHOENIX-2295<https://issues.apache.org/jira/browse/PHOENIX-2295>.

Running the query without the hint, executes the statment with a full table scan:

0: jdbc:phoenix:localhost> explain SELECT  col1, col2 FROM table1 WHERE col1='123';
+------------------------------------------+
|                   PLAN                   |
+------------------------------------------+
| CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER TABLE1 |
|     SERVER FILTER BY COL1 = '123'        |
+------------------------------------------+

Running the query wit the hint:

0: jdbc:phoenix:localhost> explain SELECT /*+ INDEX(table1 INDEX_TABLE1_COL) */ col1, col2 FROM table1 WHERE col1='123';
+------------------------------------------+
|                   PLAN                   |
+------------------------------------------+
| CLIENT 1-CHUNK PARALLEL 1-WAY FULL SCAN OVER TABLE1 |
|     SKIP-SCAN-JOIN TABLE 0               |
|         CLIENT 1-CHUNK PARALLEL 1-WAY RANGE SCAN OVER INDEX_TABLE1_COL ['123'] |
|             SERVER FILTER BY FIRST KEY ONLY |
|     DYNAMIC SERVER FILTER BY "TABLE1.ID" IN ($72.$74) |
+------------------------------------------+

Regards, Gasper

From: Alicia Shu [mailto:ashu@hortonworks.com]
Sent: Tuesday, September 29, 2015 9:24 AM
To: user@phoenix.apache.org
Subject: Re: Error with union all and a hint

By default if there is an index defined for a table, the index will be used if the plan with the index is better. Please file a Jira for the NPE.

Thanks,
Alicia

From: Gašper Metelko <ga...@salviol.com>>
Reply-To: "user@phoenix.apache.org<ma...@phoenix.apache.org>" <us...@phoenix.apache.org>>
Date: Friday, September 25, 2015 at 6:52 AM
To: "user@phoenix.apache.org<ma...@phoenix.apache.org>" <us...@phoenix.apache.org>>
Subject: Error with union all and a hint

Hi

I have a problem with executing a UNION ALL statment with added hints. I need the hints to be able to use the index. For example:

explain SELECT /*+ INDEX(table1 INDEX_TABLE1_COL) */ col1, col2 FROM table1 WHERE col1='123' UNION ALL SELECT /*+ INDEX(table2 INDEX_TABLE2_COL) */ col1, col2 FROM table2 WHERE col1='123';

I get an error:
java.lang.NullPointerException
        at java.util.ArrayList.addAll(ArrayList.java:559)
        at org.apache.phoenix.iterate.UnionResultIterators.<init>(UnionResultIterators.java:51)
        at org.apache.phoenix.execute.UnionPlan.iterator(UnionPlan.java:131)
        at org.apache.phoenix.execute.UnionPlan.iterator(UnionPlan.java:127)
        at org.apache.phoenix.execute.UnionPlan.getExplainPlan(UnionPlan.java:150)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:424)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:403)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:246)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:241)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:240)
        at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1250)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)

I am using phoenix-4.4.0-HBase-1.1, the tables and indexes are as follows. I will greatly appriciate any help.

Regards, Gasper

CREATE TABLE table1 (
  id BIGINT,
  col1 VARCHAR,
  col2 VARCHAR,
  CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true;

CREATE TABLE table2 (
  id BIGINT,
  col1 VARCHAR,
  col2 VARCHAR,
  CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true;

CREATE INDEX INDEX_TABLE1_COL ON table1 (col1);

CREATE INDEX INDEX_TABLE2_COL ON table2 (col1);



Re: Error with union all and a hint

Posted by Alicia Shu <as...@hortonworks.com>.
By default if there is an index defined for a table, the index will be used if the plan with the index is better. Please file a Jira for the NPE.

Thanks,
Alicia

From: Gašper Metelko <ga...@salviol.com>>
Reply-To: "user@phoenix.apache.org<ma...@phoenix.apache.org>" <us...@phoenix.apache.org>>
Date: Friday, September 25, 2015 at 6:52 AM
To: "user@phoenix.apache.org<ma...@phoenix.apache.org>" <us...@phoenix.apache.org>>
Subject: Error with union all and a hint

Hi

I have a problem with executing a UNION ALL statment with added hints. I need the hints to be able to use the index. For example:

explain SELECT /*+ INDEX(table1 INDEX_TABLE1_COL) */ col1, col2 FROM table1 WHERE col1='123' UNION ALL SELECT /*+ INDEX(table2 INDEX_TABLE2_COL) */ col1, col2 FROM table2 WHERE col1='123';

I get an error:
java.lang.NullPointerException
        at java.util.ArrayList.addAll(ArrayList.java:559)
        at org.apache.phoenix.iterate.UnionResultIterators.<init>(UnionResultIterators.java:51)
        at org.apache.phoenix.execute.UnionPlan.iterator(UnionPlan.java:131)
        at org.apache.phoenix.execute.UnionPlan.iterator(UnionPlan.java:127)
        at org.apache.phoenix.execute.UnionPlan.getExplainPlan(UnionPlan.java:150)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:424)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:403)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:246)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:241)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:240)
        at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1250)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)

I am using phoenix-4.4.0-HBase-1.1, the tables and indexes are as follows. I will greatly appriciate any help.

Regards, Gasper

CREATE TABLE table1 (
  id BIGINT,
  col1 VARCHAR,
  col2 VARCHAR,
  CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true;

CREATE TABLE table2 (
  id BIGINT,
  col1 VARCHAR,
  col2 VARCHAR,
  CONSTRAINT pk PRIMARY KEY (id)) IMMUTABLE_ROWS=true;

CREATE INDEX INDEX_TABLE1_COL ON table1 (col1);

CREATE INDEX INDEX_TABLE2_COL ON table2 (col1);