You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "Tim Armstrong (JIRA)" <ji...@apache.org> on 2018/11/01 01:04:00 UTC
[jira] [Resolved] (IMPALA-2172) length(CHAR) doesn't consider
trailing space
[ https://issues.apache.org/jira/browse/IMPALA-2172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tim Armstrong resolved IMPALA-2172.
-----------------------------------
Resolution: Not A Bug
> length(CHAR) doesn't consider trailing space
> --------------------------------------------
>
> Key: IMPALA-2172
> URL: https://issues.apache.org/jira/browse/IMPALA-2172
> Project: IMPALA
> Issue Type: Bug
> Components: Backend
> Affects Versions: Impala 2.0, Impala 2.1, Impala 2.2
> Reporter: Juan Yu
> Priority: Minor
>
> CHAR is represented in memory as a byte array with the same size as the length specification.
> length(CHAR) returns the total length including trailing space on some databases (see Oracle's behavior, http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions076.htm)
> In Impala it returns the trimmed length:
> {code}
> Query: select length(cast('a ' as char(4)))
> +--------------------------------+
> | length(cast('a ' as char(4))) |
> +--------------------------------+
> | 1 |
> +--------------------------------+
> {code}
> For workaround, you can use char_length to get correct length for CHAR type.
> {code}
> Query: select char_length(cast('a ' as char(4)))
> +-------------------------------------+
> | char_length(cast('a ' as char(4))) |
> +-------------------------------------+
> | 4 |
> +-------------------------------------+
> {code}
> Impala's behaviour is consistent with other databases including Mysql and Postgresql
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org