[ 
https://issues.apache.org/jira/browse/SPARK-51051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17924092#comment-17924092
 ] 

Konjac commented on SPARK-51051:
--------------------------------

 

Ternary `array_position` is not the mainstream. Most of data system only 
supports binary.

{*}Presto{*}([https://prestodb.io/docs/current/functions/array.html#array_position-x-element-instance-bigint]
 )

The third parameter is the number of occurrences.

> array_position(x, element, instance) -> 
> bigint()[¶|https://prestodb.io/docs/current/functions/array.html#array_position-x-element-instance-bigint]

> If {{{}instance > 0{}}}, returns the position of the ??instance??-th 
> occurrence of the {{element}} in array {{{}x{}}}. If {{{}instance < 0{}}}, 
> returns the position of the {{{}instance{}}}-to-last occurrence of the 
> {{element}} in array {{{}x{}}}. If no matching element instance is found, 
> {{0}} is returned.

{*}Postgresql{*}([https://www.postgresql.org/docs/17/functions-array.html] ) 

The third parameter is just the mentioned one of the description.

 
|{{{}{{{}array_position{}}}({}}}{{{}anyarray{}}}{{{}, {}}}{{anyelement}}{{ [, 
{{int}}])}}|{{int}}|returns the subscript of the first occurrence of the second 
argument in the array, starting at the element indicated by the third argument 
or at the first element (array must be 
one-dimensional)|{{array_position(ARRAY['sun','mon','tue','wed','thu','fri','sat'],
 'mon')}}|{{2}}|

> array_position function should accept an optional 'start_index' parameter
> -------------------------------------------------------------------------
>
>                 Key: SPARK-51051
>                 URL: https://issues.apache.org/jira/browse/SPARK-51051
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.5.4
>            Reporter: Shreyas
>            Priority: Major
>
> Most programming language that support "array_position" type of function have 
> an optional parameter to start from a specific index.
> For e.g. Javascript has the 
> [indexOf|https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf]
>  function that accepts *fromIndex* parameter. Same with Scala indexOf on 
> Lists as well.
> It would be nice to add that parameter to Spark's array_position function as 
> well.
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to