Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/3433#discussion_r22011924
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringOperations.scala
---
@@ -272,3 +272,31 @@ case class Substring(str: Expression, pos: Expression,
len: Expression) extends
case _ => s"SUBSTR($str, $pos, $len)"
}
}
+
+/**
+ * A function that concatenates two strings.
+ */
+case class Concat(left: Expression, right: Expression) extends
BinaryExpression {
+
+ type EvaluatedType = Any
+
+ def nullable: Boolean = left.nullable || right.nullable
+ override def dataType: DataType = StringType
+
+ override def eval(input: Row): Any = {
+ val leftEvaled = left.eval(input)
+ val rightEvaled = right.eval(input)
+
+ if (leftEvaled == null || rightEvaled == null) {
+ null
+ } else {
+ val leftStr = leftEvaled.toString
+ val rightStr = rightEvaled.toString
+ leftStr + rightStr
+ }
+ }
+
+ def symbol: String = "||"
+
+ override def toString() = s"$left $nodeName $right"
--- End diff --
This is automatically defined by `BinaryExpression`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]