[ https://issues.apache.org/jira/browse/PHOENIX-7615?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hari Krishna Dara updated PHOENIX-7615: --------------------------------------- Description: A NullPointerException is thrown when using a CASE expression to conditionally bind a value to NULL in an UPSERT statement using ON DUPLICATE KEY. Here is a sample table and an UPSERT statement that can reproduce it (we need to use JDBC to bind a NULL) {{ CREATE TABLE test_table(}} {{ row_id INTEGER NOT NULL,}} {{ chunk VARCHAR,}} {{ CONSTRAINT PK PRIMARY KEY (row_id))}} {{ UPSERT INTO test_table (row_id, chunk) VALUES (:1, :2)}} {{ ON DUPLICATE KEY UPDATE}} {{ chunk = CASE WHEN :2 IS NOT NULL THEN :2 ELSE chunk END}} Here is a sample exception stacktrace: {{java.lang.NullPointerException}} {{ at org.apache.phoenix.jdbc.PhoenixParameterMetaData.addParam(PhoenixParameterMetaData.java:161)}} {{ at org.apache.phoenix.compile.BindManager.addParamMetaData(BindManager.java:78)}} {{ at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:755)}} {{ at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:144)}} {{ at org.apache.phoenix.parse.IsNullParseNode.accept(IsNullParseNode.java:53)}} {{ at org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)}} {{ at org.apache.phoenix.parse.CaseParseNode.accept(CaseParseNode.java:45)}} {{ at org.apache.phoenix.compile.UpsertCompiler.getOnDuplicateKeyBytes(UpsertCompiler.java:928)}} {{ at org.apache.phoenix.compile.UpsertCompiler.compile(UpsertCompiler.java:873)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableUpsertStatement.compilePlan(PhoenixStatement.java:1142)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableUpsertStatement.compilePlan(PhoenixStatement.java:1128)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:626)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:607)}} {{ at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:606)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:584)}} {{ at org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:184)}} was: A NullPointerException is thrown when using a CASE expression to conditionally bind a value to NULL in an UPSERT statement using ON DUPLICATE KEY. Here is a sample table and an UPSERT statement that can reproduce it (we need to use JDBC to bind a NULL) {{ CREATE TABLE test_tale(}} {{ row_id INTEGER NOT NULL,}} {{ chunk VARCHAR,}} {{ CONSTRAINT PK PRIMARY KEY (row_id))}} {{ UPSERT INTO test_table (row_id, chunk) VALUES (:1, :2)}} {{ ON DUPLICATE KEY UPDATE}} {{ chunk = CASE WHEN :2 IS NOT NULL THEN :2 ELSE chunk END}} Here is a sample exception stacktrace: {{java.lang.NullPointerException}} {{ at org.apache.phoenix.jdbc.PhoenixParameterMetaData.addParam(PhoenixParameterMetaData.java:161)}} {{ at org.apache.phoenix.compile.BindManager.addParamMetaData(BindManager.java:78)}} {{ at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:755)}} {{ at org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:144)}} {{ at org.apache.phoenix.parse.IsNullParseNode.accept(IsNullParseNode.java:53)}} {{ at org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)}} {{ at org.apache.phoenix.parse.CaseParseNode.accept(CaseParseNode.java:45)}} {{ at org.apache.phoenix.compile.UpsertCompiler.getOnDuplicateKeyBytes(UpsertCompiler.java:928)}} {{ at org.apache.phoenix.compile.UpsertCompiler.compile(UpsertCompiler.java:873)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableUpsertStatement.compilePlan(PhoenixStatement.java:1142)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableUpsertStatement.compilePlan(PhoenixStatement.java:1128)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:626)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:607)}} {{ at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:606)}} {{ at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:584)}} {{ at org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:184)}} > NPE when NULL is bound to a CASE inside ON DUPLICATE KEY > -------------------------------------------------------- > > Key: PHOENIX-7615 > URL: https://issues.apache.org/jira/browse/PHOENIX-7615 > Project: Phoenix > Issue Type: Bug > Affects Versions: 5.3.0 > Reporter: Hari Krishna Dara > Assignee: Hari Krishna Dara > Priority: Major > > A NullPointerException is thrown when using a CASE expression to > conditionally bind a value to NULL in an UPSERT statement using ON DUPLICATE > KEY. Here is a sample table and an UPSERT statement that can reproduce it (we > need to use JDBC to bind a NULL) > > {{ CREATE TABLE test_table(}} > {{ row_id INTEGER NOT NULL,}} > {{ chunk VARCHAR,}} > {{ CONSTRAINT PK PRIMARY KEY (row_id))}} > > {{ UPSERT INTO test_table (row_id, chunk) VALUES (:1, :2)}} > {{ ON DUPLICATE KEY UPDATE}} > {{ chunk = CASE WHEN :2 IS NOT NULL THEN :2 ELSE chunk END}} > > Here is a sample exception stacktrace: > > {{java.lang.NullPointerException}} > {{ at > org.apache.phoenix.jdbc.PhoenixParameterMetaData.addParam(PhoenixParameterMetaData.java:161)}} > {{ at > org.apache.phoenix.compile.BindManager.addParamMetaData(BindManager.java:78)}} > {{ at > org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:755)}} > {{ at > org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:144)}} > {{ at > org.apache.phoenix.parse.IsNullParseNode.accept(IsNullParseNode.java:53)}} > {{ at > org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)}} > {{ at > org.apache.phoenix.parse.CaseParseNode.accept(CaseParseNode.java:45)}} > {{ at > org.apache.phoenix.compile.UpsertCompiler.getOnDuplicateKeyBytes(UpsertCompiler.java:928)}} > {{ at > org.apache.phoenix.compile.UpsertCompiler.compile(UpsertCompiler.java:873)}} > {{ at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableUpsertStatement.compilePlan(PhoenixStatement.java:1142)}} > {{ at > org.apache.phoenix.jdbc.PhoenixStatement$ExecutableUpsertStatement.compilePlan(PhoenixStatement.java:1128)}} > {{ at > org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:626)}} > {{ at > org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:607)}} > {{ at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)}} > {{ at > org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:606)}} > {{ at > org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:584)}} > {{ at > org.apache.phoenix.jdbc.PhoenixPreparedStatement.execute(PhoenixPreparedStatement.java:184)}} -- This message was sent by Atlassian Jira (v8.20.10#820010)