snowflake.snowpark.functions.array_generate_range¶

snowflake.snowpark.functions.array_generate_range(start: Union[Column, str], stop: Union[Column, str], step: Optional[Union[Column, str]] = None) → Column[source]¶

Generate a range of integers from start to stop, incrementing by step. If step is not set, incrementing by 1.

Parameters:
  • start – the column that contains the integer to start with (inclusive).

  • stop – the column that contains the integer to stop (exclusive).

  • step – the column that contains the integer to increment.

Example::
>>> from snowflake.snowpark import Row
>>> df1 = session.create_dataframe([(-2, 2)], ["a", "b"])
>>> df1.select(array_generate_range("a", "b").alias("result")).show()
------------
|"RESULT"  |
------------
|[         |
|  -2,     |
|  -1,     |
|  0,      |
|  1       |
|]         |
------------

>>> df2 = session.create_dataframe([(4, -4, -2)], ["a", "b", "c"])
>>> df2.select(array_generate_range("a", "b", "c").alias("result")).show()
------------
|"RESULT"  |
------------
|[         |
|  4,      |
|  2,      |
|  0,      |
|  -2      |
|]         |
------------
Copy