danielhumanmod commented on code in PR #2831:
URL: https://github.com/apache/datafusion-comet/pull/2831#discussion_r2583879942


##########
spark/src/main/scala/org/apache/comet/serde/strings.scala:
##########
@@ -286,3 +286,83 @@ trait CommonStringExprs {
     }
   }
 }
+
+object CometRegExpExtract extends CometExpressionSerde[RegExpExtract] {
+  override def getSupportLevel(expr: RegExpExtract): SupportLevel = {
+    // Check if the pattern is compatible with Spark or allow incompatible 
patterns
+    expr.regexp match {
+      case Literal(pattern, DataTypes.StringType) =>
+        if (!RegExp.isSupportedPattern(pattern.toString) &&
+          !CometConf.COMET_REGEXP_ALLOW_INCOMPATIBLE.get()) {
+          withInfo(
+            expr,
+            s"Regexp pattern $pattern is not compatible with Spark. " +
+              s"Set ${CometConf.COMET_REGEXP_ALLOW_INCOMPATIBLE.key}=true " +
+              "to allow it anyway.")
+          return Incompatible()
+        }
+      case _ =>
+        return Unsupported(Some("Only literal regexp patterns are supported"))
+    }
+
+    // Check if idx is a literal
+    expr.idx match {
+      case Literal(_, DataTypes.IntegerType) =>
+        Compatible()
+      case _ =>
+        Unsupported(Some("Only literal group index is supported"))
+    }
+  }
+
+  override def convert(
+      expr: RegExpExtract,
+      inputs: Seq[Attribute],
+      binding: Boolean): Option[Expr] = {
+    val subjectExpr = exprToProtoInternal(expr.subject, inputs, binding)
+    val patternExpr = exprToProtoInternal(expr.regexp, inputs, binding)
+    val idxExpr = exprToProtoInternal(expr.idx, inputs, binding)
+    val optExpr = scalarFunctionExprToProto("regexp_extract", subjectExpr, 
patternExpr, idxExpr)
+    optExprWithInfo(optExpr, expr, expr.subject, expr.regexp, expr.idx)
+  }
+}
+
+object CometRegExpExtractAll extends CometExpressionSerde[RegExpExtractAll] {
+  override def getSupportLevel(expr: RegExpExtractAll): SupportLevel = {
+    // Check if the pattern is compatible with Spark or allow incompatible 
patterns
+    expr.regexp match {
+      case Literal(pattern, DataTypes.StringType) =>
+        if (!RegExp.isSupportedPattern(pattern.toString) &&

Review Comment:
   For now it is a placeholder introduced in this 
[PR](https://github.com/danielhumanmod/datafusion-comet/commit/e33d56050187c75afcbbdc2def96a093a019db6a#diff-8aa4d7fa45d8c9eb2d228424f3c64fa2979c4072ab28dd9582729b20ccc7ade5R25)
   
   @andygrove when you have a chance, could you share a bit more context on its 
purpose? I’d really appreciate it. Thank you!



-- 
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]

Reply via email to