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", "[email protected]", "Test Ltd1"),
         row("Alice", "[email protected]", "Test Ltd2"),
         row("Alice", "[email protected]", "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()
   
   structure of the result table is as follows:
   
   (
     `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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to