sarutak commented on code in PR #49191: URL: https://github.com/apache/spark/pull/49191#discussion_r1923271004
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala: ########## @@ -3723,3 +3723,40 @@ case class Luhncheck(input: Expression) extends RuntimeReplaceable with Implicit override protected def withNewChildrenInternal( newChildren: IndexedSeq[Expression]): Expression = copy(newChildren(0)) } + +/** + * A function that prepends a backslash to each instance of single quote + * in the given string and encloses the result by single quotes. + */ +@ExpressionDescription( + usage = """ + _FUNC_(str) - Returns `str` enclosed by single quotes and + each instance of single quote in it is preceded by a backslash. + """, + examples = """ + Examples: + > SELECT _FUNC_('Don\'t'); + 'Don\'t' + """, + since = "4.0.0", + group = "string_funcs") +case class Quote(input: Expression) extends RuntimeReplaceable with ImplicitCastInputTypes + with UnaryLike[Expression] { + override def nullIntolerant: Boolean = true + + override lazy val replacement: Expression = Invoke(input, "quote", input.dataType) Review Comment: You mean for instance, implementing `quote` in `ExpressionImplUtils` and call it using `StaticInvoke` right? -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org