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

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

[~jamestaylor] Data type conversion can get complicated. Should we make some 
assumption: 

If component queries select character data, then the datatype of the return 
values are determined as follows:

If both queries select values of datatype CHAR of equal length, then the 
returned values have datatype CHAR of that length. If the queries select values 
of CHAR with different lengths, then the returned value is VARCHAR with the 
length of the larger CHAR value.

If either or both of the queries select values of datatype VARCHAR, then the 
returned values have datatype VARCHAR.

If component queries select numeric data, then the datatype of the return 
values is determined by numeric precedence:

If any query selects values of type DOUBLE, then the returned values have 
datatype DOUBLE.

If no query selects values of type DOUBLE but any query selects values of type 
FLOAT, then the returned values have datatype FLOAT.

Similar for other numeric data types. 

If there are unsigned and signed data types, convert to unsigned. 

> Union ALL with Char column  not present in the table in Query 1 but in Query 
> 2 throw exception
> ----------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-2886
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2886
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Alicia Ying Shu
>            Assignee: Alicia Ying Shu
>             Fix For: 4.8.0
>
>
> To reproduce:
> create table person ( id bigint not null primary key, firstname char(10), 
> lastname varchar(10) );
> upsert into person values( 1, 'john', 'doe');
> upsert into person values( 2, 'jane', 'doe');
> -- fixed value for char(10)
> select id, 'foo' firstname, lastname from person union all select * from 
> person;
> java.lang.RuntimeException: java.sql.SQLException: ERROR 201 (22000): Illegal 
> data. Expected length of at least 106 bytes, but had 13
> -- fixed value for bigint
> select cast( 10 AS bigint) id, 'foo' firstname, lastname from person union 
> all select * from person;
> java.lang.RuntimeException: java.sql.SQLException: ERROR 201 (22000): Illegal 
> data. Expected length of at least 106 bytes, but had 13



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

Reply via email to