[
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/30/21, 9:12 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 | CHAR =>
new LeadLagAggFunction.StringLeadLagAggFunction(argTypes.length)
{code}
was (Author: liliwei):
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}
> 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, pull-request-available, 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', '[email protected]', ARRAY [ '[email protected]' ], 'Test Ltd'),
> ('Alice', '[email protected]', ARRAY [ '[email protected]' ], 'Test Ltd'),
> ('Alice', '[email protected]', ARRAY [ '[email protected]', '[email protected]' ],
> '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)