coderfender commented on code in PR #3269:
URL: https://github.com/apache/datafusion-comet/pull/3269#discussion_r2743874786
##########
spark/src/main/scala/org/apache/comet/serde/strings.scala:
##########
@@ -289,6 +289,34 @@ object CometRegExpReplace extends
CometExpressionSerde[RegExpReplace] {
}
}
+object CometElt extends CometScalarFunction[Elt]("elt") {
+
+ override def getSupportLevel(expr: Elt): SupportLevel = {
+ if (expr.failOnError) {
+ return Unsupported(Some("ANSI mode not supported"))
+ }
+ if (expr.children.length < 2) {
+ return Unsupported(Some("The `elt` requires > 1 parameters but the
actual number is 1"))
+ }
+ val idxDataType = expr.children.head.dataType
+ if (idxDataType != IntegerType) {
+ return Unsupported(Some(s"Parameter 1 requires the int type, but got:
$idxDataType"))
+ }
+ if (!expr.children.tail.forall(_.dataType == StringType)) {
+ val unsupportedTypes =
+ expr.children.tail
+ .filter(_.dataType != StringType)
+ .map(_.dataType)
+ .distinct
+ .mkString(", ")
+ return Unsupported(
+ Some(
+ s"Parameters 2 and onwards require the string type, but contains:
$unsupportedTypes"))
Review Comment:
minor : we could use `StringType.toSQL` to get SQL test for StringType to
make it easier for user's to parse error messages
--
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]