Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/7709#discussion_r35986722
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringOperations.scala
---
@@ -284,6 +284,66 @@ case class EndsWith(left: Expression, right:
Expression)
}
/**
+ * A function translate any character in the `srcExpr` by a character in
`replaceExpr`.
+ * The characters in `replaceExpr` is corresponding to the characters in
`matchingExpr`.
+ * The translate will happen when any character in the string matching
with the character
+ * in the `matchingExpr`.
+ */
+case class StringTranslate(srcExpr: Expression, matchingExpr: Expression,
replaceExpr: Expression)
+ extends Expression with ImplicitCastInputTypes {
+
+ override def foldable: Boolean = srcExpr.foldable &&
matchingExpr.foldable && replaceExpr.foldable
+ override def nullable: Boolean = srcExpr.nullable ||
matchingExpr.nullable || replaceExpr.nullable
+
+ override def dataType: DataType = StringType
+
+ override def inputTypes: Seq[DataType] = Seq(StringType, StringType,
StringType)
+
+ override def children: Seq[Expression] = srcExpr :: matchingExpr ::
replaceExpr :: Nil
+
+ override def eval(input: InternalRow): Any = {
+ val srcEval = srcExpr.eval(input)
+ if (srcEval != null) {
+ val matchingEval = matchingExpr.eval(input)
+ if (matchingEval != null) {
--- End diff --
It's merged, could you update to use TernaryExpression ?
---
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]