snowflake.snowpark.functions.sequence¶
- snowflake.snowpark.functions.sequence(start: Union[Column, str], stop: Union[Column, str], step: Optional[Union[Column, str]] = None) Column [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/functions.py#L4893-L4962)¶
Generate a sequence of integers from start to stop, incrementing by step. If step is not set, incrementing by 1 if start is less than or equal to stop, otherwise -1.
- Parameters:
start – the column that contains the integer to start with (inclusive).
stop – the column that contains the integer to stop (inclusive).
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(sequence("a", "b").alias("result")).show() ------------ |"RESULT" | ------------ |[ | | -2, | | -1, | | 0, | | 1, | | 2 | |] | ------------ >>> df2 = session.create_dataframe([(4, -4, -2)], ["a", "b", "c"]) >>> df2.select(sequence("a", "b", "c").alias("result")).show() ------------ |"RESULT" | ------------ |[ | | 4, | | 2, | | 0, | | -2, | | -4 | |] | ------------