You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "liwei li (Jira)" <ji...@apache.org> on 2021/07/25 01:56:00 UTC

[jira] [Comment Edited] (FLINK-22405) Support fixed-lengh chars in the LeadLag built-in function

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

liwei li edited comment on FLINK-22405 at 7/25/21, 1:55 AM:
------------------------------------------------------------

I add a case statement block to match the data of CHAR type, convert them to STRING just like varchar.In my tests, the modified code executes the SQL statement in the example correctly.Is it feasible?
{code:java}
      case VARCHAR =>
        new LeadLagAggFunction.StringLeadLagAggFunction(argTypes.length)
      case CHAR =>
        new LeadLagAggFunction.StringLeadLagAggFunction(argTypes.length)
{code}


was (Author: liliwei):
I added a case statement block to match the data of CHAR type , convert them to STRING just like varchar.In my tests, the modified code executes the SQL statement in the example correctly.Is it feasible?
{code:java}
      case VARCHAR =>
        new LeadLagAggFunction.StringLeadLagAggFunction(argTypes.length)
      case CHAR =>
        new LeadLagAggFunction.StringLeadLagAggFunction(argTypes.length)
{code}

> Support fixed-lengh chars in the LeadLag built-in function
> ----------------------------------------------------------
>
>                 Key: FLINK-22405
>                 URL: https://issues.apache.org/jira/browse/FLINK-22405
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / API
>    Affects Versions: 1.12.2, 1.13.0
>            Reporter: Nico Kruber
>            Priority: Minor
>              Labels: auto-deprioritized-major, starter
>
> LeadLag aggregate function does not support type: ''CHAR'', as in the following example (a CAST to VARCHAR works around this). Technically, there should be no reason though to support STRING/VARCHAR but not CHAR:
> {code:sql}
> CREATE TEMPORARY VIEW test_cardinality AS
> SELECT * FROM ( VALUES
>   ('Alice', 'alice@test.com', ARRAY [ 'alice@test.com' ], 'Test Ltd'),
>   ('Alice', 'alice@test.com', ARRAY [ 'alice@test.com' ], 'Test Ltd'),
>   ('Alice', 'alice@test2.com', ARRAY [ 'alice@test.com', 'alice@test2.com' ], 'Test Ltd'))
> AS t ( name, email, aliases, company );
> {code}
> {code:sql}
> SELECT
>   name,
>   LEAD(company, 0) AS company
> FROM test_cardinality
> WHERE CARDINALITY(aliases) >= 2
> GROUP BY name;
> {code}
> -> see https://github.com/apache/flink/blob/release-1.13.0-rc1/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/utils/AggFunctionFactory.scala#L331



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