Generalized array_position
to get at most n element and start from certain position.
#8145
Labels
enhancement
New feature or request
Is your feature request related to a problem or challenge?
While cleanup
array_position
I find we can extend it have better feature easily #7988Background
array_position
is the early function that follows on Postgresql.There are three types of interface now.
array_position(array, element)
is the basic one.array_position(array, element, index)
finds the elementstart_from
index.array_positions(array, element)
return all the occurrence of the elements.Problem
We are not able to find n element start from certain index.
Proposal 1 Extend the current interface
array_position(array, element, Option<index>, Option<n>)
that able us to find n elements start fromindex
andarray_positions(array, element, Option<index>)
that able us to find all the elements start fromindex
.Proposal 2 Introduce
array_position_n
array_position(array, element, Option<index>)
that able us to find 1 element start fromindex
.array_position_n(array, element, n, Option<index>)
that able us to find n elements start fromindex
.array_positions(array, element, Option<index>)
that able us to find all the elements start fromindex
.I think either of two are good for me, so I would like to collect feedbacks from yours.
Others than PostgreSQL
Duckdb
list_position(list, element)
has only the basic one.Clickhouse
None
Spark
array_position(column: Column, value: Any)
has only the basic one.Azure
array_position(array, element)
has only the basic one.Note
I had not yet find other SQL have the similar function, so I'm not sure if this feature is helpful or not.
Describe the solution you'd like
Extend
array_position
Describe alternatives you've considered
Keep it as it is.
Additional context
No response
The text was updated successfully, but these errors were encountered: