Github user hequn8128 commented on a diff in the pull request:
https://github.com/apache/flink/pull/6188#discussion_r197640442
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/time.scala
---
@@ -328,6 +330,71 @@ case class TemporalOverlaps(
}
}
+ /**
+ * Standard conversion of the TIMESTAMPADD operator.
+ * Source:
[[org.apache.calcite.sql2rel.StandardConvertletTable#TimestampAddConvertlet]]
+ */
+case class TimestampAdd(
+ unit: Expression,
+ count: Expression,
+ timestamp: Expression)
+ extends Expression {
+
+ private[flink] final val sqlTsiArray = Array("SQL_TSI_YEAR",
"SQL_TSI_QUARTER", "SQL_TSI_MONTH",
+ "SQL_TSI_WEEK", "SQL_TSI_DAY", "SQL_TSI_HOUR", "SQL_TSI_MINUTE",
"SQL_TSI_SECOND")
+
+ override private[flink] def children: Seq[Expression] = unit :: count ::
timestamp :: Nil
+
+ override private[flink] def validateInput(): ValidationResult = {
+ if (!TypeCheckUtils.isString(unit.resultType)) {
--- End diff --
1. Not only a string, but also should be a valid unit, i.e., must be YEAR
MONTH...
2. Check count is a type of Integer or Long
3. Add ValidationTest, you can refer to the tests in
`ScalarFunctionsValidationTest`
---