[ https://issues.apache.org/jira/browse/PHOENIX-2934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15313067#comment-15313067 ]
Alicia Ying Shu commented on PHOENIX-2934: ------------------------------------------ I added the check for desiredMaxLength > b.length for PChar. The super class is PDataType which is for all data types. Do we need check it for all data types? Plus, when I put the check in the super class PDataType.java coerceBytes(), I got the following exception. {code} java.lang.IllegalArgumentException: fromIndex(7) > toIndex(3) at java.util.Arrays.rangeCheck(Arrays.java:794) at java.util.Arrays.fill(Arrays.java:2048) at org.apache.phoenix.schema.types.PDataType.coerceBytes(PDataType.java:824) at org.apache.phoenix.schema.types.PDataType.coerceBytes(PDataType.java:799) at org.apache.phoenix.expression.CoerceExpression.evaluate(CoerceExpression.java:149) at org.apache.phoenix.schema.KeyValueSchema.toBytes(KeyValueSchema.java:112) at org.apache.phoenix.execute.TupleProjector.projectResults(TupleProjector.java:244) at org.apache.phoenix.execute.TupleProjectionPlan$1.next(TupleProjectionPlan.java:77) at org.apache.phoenix.iterate.LookAheadResultIterator$1.advance(LookAheadResultIterator.java:47) at org.apache.phoenix.iterate.LookAheadResultIterator.init(LookAheadResultIterator.java:59) at org.apache.phoenix.iterate.LookAheadResultIterator.peek(LookAheadResultIterator.java:73) at org.apache.phoenix.iterate.ConcatResultIterator.currentIterator(ConcatResultIterator.java:100) at org.apache.phoenix.iterate.ConcatResultIterator.next(ConcatResultIterator.java:117) at org.apache.phoenix.jdbc.PhoenixResultSet.next(PhoenixResultSet.java:778) at org.apache.phoenix.end2end.UnionAllIT.testCoerceExpr(UnionAllIT.java:777) {code} > Checking a coerce expression at top level should not be necessary for Union > All query > ------------------------------------------------------------------------------------- > > Key: PHOENIX-2934 > URL: https://issues.apache.org/jira/browse/PHOENIX-2934 > Project: Phoenix > Issue Type: Bug > Reporter: Alicia Ying Shu > Assignee: Alicia Ying Shu > Attachments: PHOENIX-2934.patch > > > When working on PHOENIX-2886, found that we need special handling of coerce > expression. Otherwise the following query would fail. > {code} > create table person ( id bigint not null primary key, firstname char(10), > lastname varchar(10) ); > select id, cast( 'foo' as char(10)) firstname, lastname from person union all > select * from person; > {code} > Checking a coerce expression at top level should not be necessary. Need to > find out root cause on coerceExpression. -- This message was sent by Atlassian JIRA (v6.3.4#6332)