[ 
https://issues.apache.org/jira/browse/PHOENIX-2631?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Nick Dimiduk updated PHOENIX-2631:
----------------------------------
    Description: 
I get a stack trace when querying or explaining a query that contains a 
timestamp value on the boundary of the day.

{noformat}
> CREATE TABLE FOO(
  a VARCHAR NOT NULL,
  b TIMESTAMP NOT NULL,
  c VARCHAR,
  CONSTRAINT pk PRIMARY KEY (a, b DESC ROW_TIMESTAMP, c)
) IMMUTABLE_ROWS=true,
  SALT_BUCKETS=20
;
No rows affected (1.532 seconds)
> explain select * from foo where a = 'a' and b >= timestamp '2016-01-28 
> 00:00:00' and b < timestamp '2016-01-29 00:00:00';
Error: ERROR 201 (22000): Illegal data. (state=22000,code=201)
java.sql.SQLException: ERROR 201 (22000): Illegal data.
        at 
org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:419)
        at 
org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:145)
        at 
org.apache.phoenix.schema.types.PDataType.newIllegalDataException(PDataType.java:286)
        at 
org.apache.phoenix.schema.types.PUnsignedInt$UnsignedIntCodec.decodeInt(PUnsignedInt.java:165)
        at 
org.apache.phoenix.schema.types.PTimestamp.toObject(PTimestamp.java:108)
        at 
org.apache.phoenix.schema.types.PTimestamp.toObject(PTimestamp.java:32)
        at 
org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:968)
        at 
org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:972)
        at 
org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:1001)
        at 
org.apache.phoenix.schema.types.PDataType.toStringLiteral(PDataType.java:1074)
        at 
org.apache.phoenix.schema.types.PDataType.toStringLiteral(PDataType.java:1070)
        at 
org.apache.phoenix.iterate.ExplainTable.appendPKColumnValue(ExplainTable.java:194)
        at 
org.apache.phoenix.iterate.ExplainTable.appendScanRow(ExplainTable.java:270)
        at 
org.apache.phoenix.iterate.ExplainTable.appendKeyRanges(ExplainTable.java:282)
        at 
org.apache.phoenix.iterate.ExplainTable.explain(ExplainTable.java:125)
        at 
org.apache.phoenix.iterate.BaseResultIterators.explain(BaseResultIterators.java:830)
        at 
org.apache.phoenix.iterate.RoundRobinResultIterator.explain(RoundRobinResultIterator.java:153)
        at 
org.apache.phoenix.execute.BaseQueryPlan.getPlanSteps(BaseQueryPlan.java:468)
        at 
org.apache.phoenix.execute.BaseQueryPlan.iterator(BaseQueryPlan.java:322)
        at 
org.apache.phoenix.execute.BaseQueryPlan.iterator(BaseQueryPlan.java:193)
        at 
org.apache.phoenix.execute.BaseQueryPlan.getExplainPlan(BaseQueryPlan.java:463)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:459)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:438)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:266)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:261)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:260)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1349)
        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)
{noformat}

In this case, down in {{PUnsignedInt$UnsignedIntCodec#decodeInt}}, I see the 
parsed {{v}} is {{-1}}, and the if clause throws.

  was:
I get a stack trace when querying or explaining a query that contains a 
timestamp value on the boundary of the day.

{noformat}
> create table foo(bar integer not null, ts timestamp not null, baz varchar, 
> constraint pk primary key (bar, ts desc row_timestamp, baz));
No rows affected (1.532 seconds)
> explain select * from foo where ts >= timestamp '2016-01-25 00:00:00' and ts 
> < '2016-01-26 00:00:00';
Error: ERROR 203 (22005): Type mismatch. TIMESTAMP and VARCHAR for TS < 
'2016-01-26 00:00:00' (state=22005,code=203)
org.apache.phoenix.schema.TypeMismatchException: ERROR 203 (22005): Type 
mismatch. TIMESTAMP and VARCHAR for TS < '2016-01-26 00:00:00'
        at 
org.apache.phoenix.schema.TypeMismatchException.newException(TypeMismatchException.java:53)
        at 
org.apache.phoenix.expression.ComparisonExpression.create(ComparisonExpression.java:133)
        at 
org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:228)
        at 
org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:141)
        at 
org.apache.phoenix.parse.ComparisonParseNode.accept(ComparisonParseNode.java:47)
        at 
org.apache.phoenix.parse.CompoundParseNode.acceptChildren(CompoundParseNode.java:64)
        at org.apache.phoenix.parse.AndParseNode.accept(AndParseNode.java:47)
        at 
org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:130)
        at 
org.apache.phoenix.compile.WhereCompiler.compile(WhereCompiler.java:100)
        at 
org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:537)
        at 
org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:490)
        at 
org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:201)
        at 
org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:158)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:383)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:357)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:442)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:422)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:263)
        at 
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:258)
        at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:257)
        at 
org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1438)
        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)
{noformat}

In this case, down in {{PUnsignedInt$UnsignedIntCodec#decodeInt}}, I see the 
parsed {{v}} is {{-1}}, and the if clause throws.


::sigh:: That was a bogus report. Updated the description with the actual 
example.

> Exception when parsing boundary timestamp values
> ------------------------------------------------
>
>                 Key: PHOENIX-2631
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2631
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.6.0, 4.7.0
>            Reporter: Nick Dimiduk
>
> I get a stack trace when querying or explaining a query that contains a 
> timestamp value on the boundary of the day.
> {noformat}
> > CREATE TABLE FOO(
>   a VARCHAR NOT NULL,
>   b TIMESTAMP NOT NULL,
>   c VARCHAR,
>   CONSTRAINT pk PRIMARY KEY (a, b DESC ROW_TIMESTAMP, c)
> ) IMMUTABLE_ROWS=true,
>   SALT_BUCKETS=20
> ;
> No rows affected (1.532 seconds)
> > explain select * from foo where a = 'a' and b >= timestamp '2016-01-28 
> > 00:00:00' and b < timestamp '2016-01-29 00:00:00';
> Error: ERROR 201 (22000): Illegal data. (state=22000,code=201)
> java.sql.SQLException: ERROR 201 (22000): Illegal data.
>       at 
> org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:419)
>       at 
> org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:145)
>       at 
> org.apache.phoenix.schema.types.PDataType.newIllegalDataException(PDataType.java:286)
>       at 
> org.apache.phoenix.schema.types.PUnsignedInt$UnsignedIntCodec.decodeInt(PUnsignedInt.java:165)
>       at 
> org.apache.phoenix.schema.types.PTimestamp.toObject(PTimestamp.java:108)
>       at 
> org.apache.phoenix.schema.types.PTimestamp.toObject(PTimestamp.java:32)
>       at 
> org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:968)
>       at 
> org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:972)
>       at 
> org.apache.phoenix.schema.types.PDataType.toObject(PDataType.java:1001)
>       at 
> org.apache.phoenix.schema.types.PDataType.toStringLiteral(PDataType.java:1074)
>       at 
> org.apache.phoenix.schema.types.PDataType.toStringLiteral(PDataType.java:1070)
>       at 
> org.apache.phoenix.iterate.ExplainTable.appendPKColumnValue(ExplainTable.java:194)
>       at 
> org.apache.phoenix.iterate.ExplainTable.appendScanRow(ExplainTable.java:270)
>       at 
> org.apache.phoenix.iterate.ExplainTable.appendKeyRanges(ExplainTable.java:282)
>       at 
> org.apache.phoenix.iterate.ExplainTable.explain(ExplainTable.java:125)
>       at 
> org.apache.phoenix.iterate.BaseResultIterators.explain(BaseResultIterators.java:830)
>       at 
> org.apache.phoenix.iterate.RoundRobinResultIterator.explain(RoundRobinResultIterator.java:153)
>       at 
> org.apache.phoenix.execute.BaseQueryPlan.getPlanSteps(BaseQueryPlan.java:468)
>       at 
> org.apache.phoenix.execute.BaseQueryPlan.iterator(BaseQueryPlan.java:322)
>       at 
> org.apache.phoenix.execute.BaseQueryPlan.iterator(BaseQueryPlan.java:193)
>       at 
> org.apache.phoenix.execute.BaseQueryPlan.getExplainPlan(BaseQueryPlan.java:463)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:459)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableExplainStatement.compilePlan(PhoenixStatement.java:438)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:266)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:261)
>       at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:260)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1349)
>       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)
> {noformat}
> In this case, down in {{PUnsignedInt$UnsignedIntCodec#decodeInt}}, I see the 
> parsed {{v}} is {{-1}}, and the if clause throws.



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

Reply via email to