Jack Steenkamp created PHOENIX-5087:
---------------------------------------
Summary: Inner Join Cursor Query fails with NullPointerException -
JoinCompiler.java:187
Key: PHOENIX-5087
URL: https://issues.apache.org/jira/browse/PHOENIX-5087
Project: Phoenix
Issue Type: Bug
Affects Versions: 4.14.1
Reporter: Jack Steenkamp
Attachments: PhoenixInnerJoinCursorTest.java
I have come across an inner join query in my application that fails with the
NullPointerException if executed as part of a Cursor, but executes fine if done
without it.
To reproduce this issue, you can run the attached program (assuming you update
the JDBC_URL to point to an instance you have running) or you can follow the
steps below:
Create the Table:
CREATE TABLE IF NOT EXISTS MY_STATS
(
ID VARCHAR NOT NULL,
ENTRY_NAME VARCHAR ,
ENTRY_VALUE DOUBLE ,
TRANSACTION_TIME TIMESTAMP ,
CONSTRAINT pk PRIMARY KEY(ID)
)
IMMUTABLE_STORAGE_SCHEME=ONE_CELL_PER_COLUMN,
UPDATE_CACHE_FREQUENCY=900000,
COLUMN_ENCODED_BYTES=NONE,
IMMUTABLE_ROWS=true
Execute a normal query (this works fine):
SELECT * FROM MY_STATS
INNER JOIN
(
SELECT ENTRY_NAME, MAX(TRANSACTION_TIME) AS TRANSACTION_TIME
FROM MY_STATS
GROUP BY ENTRY_NAME
) sub
ON MY_STATS.ENTRY_NAME = sub.ENTRY_NAME AND MY_STATS.TRANSACTION_TIME =
sub.TRANSACTION_TIME
ORDER BY MY_STATS.TRANSACTION_TIME DESC
Now if you execute the same query, but with the cursor declaration at the top -
DECLARE MyCursor CURSOR FOR
It produces the following exception:
Exception in thread "main" java.lang.NullPointerException
at
org.apache.phoenix.compile.JoinCompiler$JoinTableConstructor.resolveTable(JoinCompiler.java:187)
at
org.apache.phoenix.compile.JoinCompiler$JoinTableConstructor.visit(JoinCompiler.java:224)
at
org.apache.phoenix.compile.JoinCompiler$JoinTableConstructor.visit(JoinCompiler.java:181)
at org.apache.phoenix.parse.DerivedTableNode.accept(DerivedTableNode.java:49)
at
org.apache.phoenix.compile.JoinCompiler$JoinTableConstructor.visit(JoinCompiler.java:201)
at
org.apache.phoenix.compile.JoinCompiler$JoinTableConstructor.visit(JoinCompiler.java:181)
at org.apache.phoenix.parse.JoinTableNode.accept(JoinTableNode.java:81)
at org.apache.phoenix.compile.JoinCompiler.compile(JoinCompiler.java:138)
at
org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:190)
at org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:153)
at
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:490)
at
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableDeclareCursorStatement.compilePlan(PhoenixStatement.java:950)
at
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableDeclareCursorStatement.compilePlan(PhoenixStatement.java:941)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:401)
at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:391)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at
org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:390)
at
org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:378)
at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1825)
at
com.jsteenkamp.phoenix.PhoenixInnerJoinCursorTest.testCursorQuery(PhoenixInnerJoinCursorTest.java:68)
at
com.jsteenkamp.phoenix.PhoenixInnerJoinCursorTest.main(PhoenixInnerJoinCursorTest.java:20)
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)