You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2021/08/03 09:46:04 UTC
[GitHub] [flink] hililiwei commented on a change in pull request #16650: [FLINK-22405] [Table SQL / API] Support fixed-lengh chars in the Lead…
hililiwei commented on a change in pull request #16650:
URL: https://github.com/apache/flink/pull/16650#discussion_r681606529
##########
File path: flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/AggFunctionFactory.scala
##########
@@ -366,7 +366,7 @@ class AggFunctionFactory(
new LeadLagAggFunction.DoubleLeadLagAggFunction(argTypes.length)
case BOOLEAN =>
new LeadLagAggFunction.BooleanLeadLagAggFunction(argTypes.length)
- case VARCHAR =>
+ case VARCHAR | CHAR =>
new LeadLagAggFunction.StringLeadLagAggFunction(argTypes.length)
Review comment:
Although String is used in these processes, my tests show that the field type returned by Lead and Lag in the result table is still CHAR.As shown below, is this test correct? Thank you.
val testCardinality = tableEnv.fromValues(
DataTypes.ROW(
DataTypes.FIELD("name", DataTypes.STRING()),
DataTypes.FIELD("email", DataTypes.VARCHAR(20)),
DataTypes.FIELD("company", DataTypes.CHAR(10))
),
row("Alice", "alice@test.com", "Test Ltd1"),
row("Alice", "alice@test.com", "Test Ltd2"),
row("Alice", "alice@test.com", "Test Ltd3")
)
tableEnv.executeSql(
s"""
|CREATE TEMPORARY VIEW testLeadLag AS
|SELECT
| name,
| email,
| company,
| LEAD(company, 1,'null') over (
| partition by name
|) AS companyLead,
| LAG(company, 1,'null') over (
| partition by name
|) AS companyLag
|
|FROM ${testCardinality}
|""".stripMargin)
val tableLeadLag = tableEnv.from("testLeadLag")
tableLeadLag.printSchema()
result table structure is :
(
`name` STRING,
`email` VARCHAR(20),
`company` CHAR(10),
`companyLead` CHAR(10) NOT NULL,
`companyLag` CHAR(10) NOT NULL
)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org