snowflake.snowpark.Session.generator¶
- Session.generator(*columns: Column, rowcount: int = 0, timelimit: int = 0) DataFrame[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.42.0/src/snowflake/snowpark/session.py#L2809-L2928)¶
- Creates a new DataFrame using the Generator table function. - References: Snowflake Generator function. - Parameters:
- columns – List of data generation function that work in tandem with generator table function. 
- rowcount – Resulting table with contain - rowcountrows if only this argument is specified. Defaults to 0.
- timelimit – The query runs for - timelimitseconds, generating as many rows as possible within the time frame. The exact row count depends on the system speed. Defaults to 0.
 
 - Usage Notes:
- When both - rowcountand- timelimitare specified, then:- if the - rowcountis reached before the- timelimit, the resulting table with contain- rowcountrows.
- if the - timelimitis reached before the- rowcount, the table will contain as many rows generated within this time.
 
- If both - rowcountand- timelimitare not specified, 0 rows will be generated.
 
- Example 1
- >>> from snowflake.snowpark.functions import seq1, seq8, uniform >>> df = session.generator(seq1(1).as_("sequence one"), uniform(1, 10, 2).as_("uniform"), rowcount=3) >>> df.show() ------------------------------ |"sequence one" |"UNIFORM" | ------------------------------ |0 |3 | |1 |3 | |2 |3 | ------------------------------ 
- Example 2
- >>> df = session.generator(seq8(0), uniform(1, 10, 2), timelimit=1).order_by(seq8(0)).limit(3) >>> df.show() ----------------------------------- |"SEQ8(0)" |"UNIFORM(1, 10, 2)" | ----------------------------------- |0 |3 | |1 |3 | |2 |3 | ----------------------------------- 
 - Returns:
- A new - DataFramewith data from calling the generator table function.