flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-9559) The type of a union of CHAR columns of different lengths should be VARCHAR
Date Tue, 28 Aug 2018 08:44:00 GMT

    [ https://issues.apache.org/jira/browse/FLINK-9559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16594711#comment-16594711

ASF GitHub Bot commented on FLINK-9559:

hequn8128 commented on issue #6519: [FLINK-9559] [table] The type of a union of CHAR columns
of different lengths should be VARCHAR
URL: https://github.com/apache/flink/pull/6519#issuecomment-416501305
   @pnowojski  Thanks for looking into it.
    I think there are bugs in all your 4 sqls, so we can't get the conclusions from them.
   - In mysql, trailing spaces are removed when CHAR values are retrieved from a table. 
   - You use literal of length 3('aa ') to compare to CHAR(4) and VARCHAR(4).
   - Except for mysql, other database will not remove trailing spaces so that the result of
`case when` contains blanks.
   What result type of `case when`? Should we change case when result type to varchar? I think
we can get the answer form the following sqls.
   1. Mysql
   There are no doubt, since mysql Reference Manual says the return type is VARCHAR.
   2. Oracle
   3. PostgreSql
   4. SqlServer
   From the results, we can see that
   - There are no trailing spaces 
   - The result type length should not be 1, i.e., can not be char(1) or varchar(1). It should
be char(3) or varchar(3)
   - Result of `concat(CAST('a' AS char(3)), '|')` contains blanks while `concat(CAST('a'
AS varchar(3)), '|')`  not, so the result type of `case when` should be varchar.
   I think it is meaningful to turn the result type of `case when` to VARCHAR. What do you
   Thanks, Hequn

This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

> The type of a union of CHAR columns of different lengths should be VARCHAR
> --------------------------------------------------------------------------
>                 Key: FLINK-9559
>                 URL: https://issues.apache.org/jira/browse/FLINK-9559
>             Project: Flink
>          Issue Type: Bug
>          Components: Table API &amp; SQL
>            Reporter: Hequn Cheng
>            Assignee: Hequn Cheng
>            Priority: Major
>              Labels: pull-request-available
> Currently, If the case-when expression has two branches which return string literal,
redundant white spaces will be appended to the short string literal. For example, for the
sql: case 1 when 1 then 'a' when 2 then 'bcd' end, the return value will be 'a ' of CHAR(3)
instead of 'a'.
> Although, this follows the behavior in strict SQL standard mode(SQL:2003). We should
get the pragmatic return type in a real scenario without blank-padded. 
> Happily, this problem has been fixed by [CALCITE-2321|https://issues.apache.org/jira/browse/CALCITE-2321],
we can upgrade calcite to the next release(1.17.0) and override {{RelDataTypeSystem}} in flink
to configure the return type, i.e., making {{shouldConvertRaggedUnionTypesToVarying()}} return

This message was sent by Atlassian JIRA

View raw message