You are viewing documentation about an older version (1.4.0). View latest version

snowflake.snowpark.functions.array_position

snowflake.snowpark.functions.array_position(variant: ColumnOrName, array: ColumnOrName) Column[source]

Returns the index of the first occurrence of an element in an ARRAY.

Parameters:
  • variant – Column containing the VARIANT value that you want to find. The function searches for the first occurrence of this value in the array.

  • array – Column containing the ARRAY to be searched.

Example::
>>> from snowflake.snowpark import Row
>>> df = session.create_dataframe([Row([2, 1]), Row([1, 3])], schema=["a"])
>>> df.select(array_position(lit(1), "a").alias("result")).show()
------------
|"RESULT"  |
------------
|1         |
|0         |
------------
Copy