[ 
https://issues.apache.org/jira/browse/PHOENIX-2934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15309428#comment-15309428
 ] 

Alicia Ying Shu commented on PHOENIX-2934:
------------------------------------------

Looked into the codes, the issue was caused by compilation time rewrite of the 
coerce expression. 

For example:
select id, cast('foo' as char(10)) firstname, lastname from person;

In ProjectionCompiler.java, 
{code}
public static RowProjector compile(StatementContext context, SelectStatement 
statement, GroupBy groupBy, List<? extends PDatum> targetColumns, Expression 
where) throws SQLException {
....
Expression expression = node.accept(selectVisitor);
                projectedExpressions.add(expression);
{code}
After node.accept(selectVisitor), cast('foo' as char(10)) becomes 
to_char('foo'), the maxLength=3. For Union All query, we would expect the 
MaxLength=10.


> 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
>
> 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)

Reply via email to