snowflake.snowpark.Session.sql¶
- Session.sql(query: str, params: Sequence[Any] | None = None) DataFrame [source]¶
Returns a new DataFrame representing the results of a SQL query. You can use this method to execute a SQL statement. Note that you still need to call
DataFrame.collect()
to execute this query in Snowflake.- Parameters:
query – The SQL statement to execute.
params – binding parameters.
Example:
>>> # create a dataframe from a SQL query >>> df = session.sql("select 1/2") >>> # execute the query >>> df.collect() [Row(1/2=Decimal('0.500000'))]