[ https://issues.apache.org/jira/browse/FLINK-6975?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16083654#comment-16083654 ]
ASF GitHub Bot commented on FLINK-6975: --------------------------------------- Github user wuchong commented on a diff in the pull request: https://github.com/apache/flink/pull/4274#discussion_r126881414 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/stringExpressions.scala --- @@ -277,3 +278,47 @@ case class Overlay( position.toRexNode) } } + +/** + * Returns the string that results from concatenating the arguments. + * Returns NULL if any argument is NULL. + */ +case class Concat(strings: Seq[Expression]) extends Expression with InputTypeSpec { + + override private[flink] def children: Seq[Expression] = strings + + override private[flink] def resultType: TypeInformation[_] = BasicTypeInfo.STRING_TYPE_INFO + + override private[flink] def expectedTypes: Seq[TypeInformation[_]] = STRING_TYPE_INFO :: Nil + + override def toString: String = s"Concat($strings)" + + + override private[flink] def toRexNode(implicit relBuilder: RelBuilder): RexNode = { + relBuilder.call(ScalarSqlFunctions.CONCAT, children.map(_.toRexNode)) + } +} + +/** + * Returns the string that results from concatenating the arguments and separator. + * Returns NULL If the separator is NULL. + * + * Note: this user-defined function does not skip empty strings. However, it does skip any NULL + * values after the separator argument. + **/ +case class ConcatWs(separator: Expression, strings: Seq[Expression]) + extends Expression with InputTypeSpec { + + override private[flink] def children: Seq[Expression] = Seq(separator) ++ strings + + override private[flink] def resultType: TypeInformation[_] = BasicTypeInfo.STRING_TYPE_INFO + + override private[flink] def expectedTypes: Seq[TypeInformation[_]] = STRING_TYPE_INFO :: Nil --- End diff -- The `expectedTypes` should be the same size as children with `STRING_TYPE_INFO`. All the tests passed, because there is a bug in `InputTypeSpec#validateInput` which do not check the size of `expectedTypes` and `children`. It would be great if we can fix it in this PR. > Add CONCAT/CONCAT_WS supported in TableAPI > ------------------------------------------ > > Key: FLINK-6975 > URL: https://issues.apache.org/jira/browse/FLINK-6975 > Project: Flink > Issue Type: Sub-task > Components: Table API & SQL > Affects Versions: 1.4.0 > Reporter: sunjincheng > Assignee: sunjincheng > Labels: starter > > See FLINK-6925 for detail. -- This message was sent by Atlassian JIRA (v6.4.14#64029)