snowflake.snowpark.Session.generator¶
- Session.generator(*columns: Column, rowcount: int = 0, timelimit: int = 0) DataFrame[source]¶
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
rowcountandtimelimitare specified, then:if the
rowcountis reached before thetimelimit, the resulting table with containrowcountrows.if the
timelimitis reached before therowcount, the table will contain as many rows generated within this time.
If both
rowcountandtimelimitare 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.