loftiest commented on code in PR #56498:
URL: https://github.com/apache/spark/pull/56498#discussion_r3442540172


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala:
##########
@@ -1701,6 +1730,79 @@ case class StringInstr(str: Expression, substr: 
Expression)
     newLeft: Expression, newRight: Expression): StringInstr = copy(str = 
newLeft, substr = newRight)
 }
 
+/**
+ * A function that returns the position of the specified occurrence of 
`substr` in the given
+ * string, starting the search from position `start`. If `start` is positive, 
the search proceeds
+ * forward; if `start` is negative, the search proceeds backward. `start` = 0 
returns 0. If
+ * `start` is not specified, it defaults to 1. If `occurrence` is specified, 
it determines which
+ * occurrence of `substr` to return; `occurrence` must be a positive integer 
and defaults to 1.
+ *
+ * Returns null if either of the arguments are null and
+ * returns 0 if substr could not be found in str.
+ *
+ * NOTE: that this is not zero based, but 1-based index. The first character 
in str has index 1.
+ */
+case class StringInstrWithOccurrence(
+    str: Expression,
+    sub: Expression,
+    start: Expression,
+    occurrence: Expression,
+    failOnError: Boolean = SQLConf.get.ansiEnabled)

Review Comment:
   Thanks for the clear rationale. I've removed the ANSI‑gated path entirely — 
`occurrence <= 0` now always throws `INVALID_PARAMETER_VALUE.OCCURRENCE`, with 
no `failOnError` field or null‑return branch.



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