uros-b commented on code in PR #56498:
URL: https://github.com/apache/spark/pull/56498#discussion_r3420899191


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringExpressions.scala:
##########
@@ -1651,24 +1651,53 @@ case class StringTrimRight(srcStr: Expression, trimStr: 
Option[Expression] = Non
       trimStr = if (trimStr.isDefined) Some(newChildren.last) else None)
 }
 
-/**
- * A function that returns the position of the first occurrence of substr in 
the given string.
- * 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.
- */
 // scalastyle:off line.size.limit
 @ExpressionDescription(
-  usage = "_FUNC_(str, substr) - Returns the (1-based) index of the first 
occurrence of `substr` in `str`.",
+  usage = """
+    _FUNC_(str, substr[, start[, occurrence]]) - Returns the (1-based) index 
of the specified
+      occurrence of `substr` in `str`, 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.
+      `occurrence` must be a positive integer and defaults to 1.
+  """,
   examples = """
     Examples:
       > SELECT _FUNC_('SparkSQL', 'SQL');
        6
+      > SELECT _FUNC_('abcabc', 'b', 1);
+       2
+      > SELECT _FUNC_('abcabc', 'b', 1, 2);
+       5
+      > SELECT _FUNC_('abcabc', 'b', -1, 1);
+       5
   """,
   since = "1.5.0",
   group = "string_funcs")
 // scalastyle:on line.size.limit
+object StringInstrExpressionBuilder extends ExpressionBuilder {

Review Comment:
   There are some unused auxiliary constructors. `StringInstr4` defines three 
`def this(...)` overloads (2/3/4-arg), but `StringInstrExpressionBuilder` 
constructs the case class directly with explicit Literal(1) defaults, so these 
constructors appear to be dead code. Either use them from the builder or drop 
them.



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