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

Quanlong Huang commented on IMPALA-1652:
----------------------------------------

I also vote for option 2. More ideally, I think we should ignore trailing 
spaces of CHAR values in all operations.
{quote}So we should consider fixing this by making casts from char to string 
strip trailing whitespace. It would need a bit more investigation to see if 
that fully matches Hive behaviour, but I think it seems viable.
{quote}
If the planner implicitly cast char columns to string types, will it impact 
performance? Intuitively, when there are many exprs refering the CHAR column, 
the trailing whitespaces need to be removed many times. Maybe we can store the 
actual length of each CHAR value in the tuple layout, and calculte the actual 
length once when materializing the value. Not sure how much this can improve, 
but it's also an optimization which will benifit the work in supporting UTF-8 
CHAR type (IMPALA-5675). In UTF8_MODE, char(N) will mean at-most N utf8 
characters. The actual length in bytes is also variable.

> Fix CHAR datatype: Incorrect results with basic predicate on CHAR typed 
> column.
> -------------------------------------------------------------------------------
>
>                 Key: IMPALA-1652
>                 URL: https://issues.apache.org/jira/browse/IMPALA-1652
>             Project: IMPALA
>          Issue Type: Bug
>          Components: Backend
>    Affects Versions: Impala 2.1, Impala 2.3.0
>            Reporter: Alexander Behm
>            Priority: Major
>              Labels: correctness, downgraded, usability
>         Attachments: 8be18d4.diff
>
>
> Repro:
> {code}
> create table foo(col1 char(10));
> insert into foo values (cast('test1' as char(10)));
> select * from foo where col1 = 'test1'; <-- returns an empty result set
> select * from foo where col1 = cast('test1' as char(10)); <-- correctly 
> returns 1 row
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to