kazantsev-maksim commented on code in PR #2548:
URL: https://github.com/apache/datafusion-comet/pull/2548#discussion_r2426819184
##########
spark/src/main/scala/org/apache/comet/serde/strings.scala:
##########
@@ -204,6 +204,49 @@ object CometStringLPad extends
CometExpressionSerde[StringLPad] {
}
}
+object CometRegExpReplace extends CometExpressionSerde[RegExpReplace] {
+ override def getSupportLevel(expr: RegExpReplace): SupportLevel = {
+ if (!RegExp.isSupportedPattern(expr.regexp.toString) &&
+ !CometConf.COMET_REGEXP_ALLOW_INCOMPATIBLE.get()) {
+ withInfo(
+ expr,
+ s"Regexp pattern ${expr.regexp} is not compatible with Spark. " +
+ s"Set ${CometConf.COMET_REGEXP_ALLOW_INCOMPATIBLE.key}=true " +
+ "to allow it anyway.")
+ return Incompatible()
+ }
+ expr.pos match {
+ case Literal(value, DataTypes.IntegerType) if value == 1 => Compatible()
+ case _ =>
+ Unsupported(Some("Comet only supports regexp_replace with an offset of
1 (no offset)."))
+ }
+ }
+
+ override def convert(
+ expr: RegExpReplace,
+ inputs: Seq[Attribute],
+ binding: Boolean): Option[Expr] = {
+ expr.pos match {
Review Comment:
Do we need this condition here? It's already defined in the getSupportLevel
function.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]