snowflake.snowpark.Session.query_history¶
- Session.query_history(include_describe: bool = False, include_thread_id: bool = False, include_error: bool = False) QueryHistory [source] (https://github.com/snowflakedb/snowpark-python/blob/v1.26.0/snowpark-python/src/snowflake/snowpark/session.py#L3997-L4022)¶
Create an instance of
QueryHistory
as a context manager to record queries that are pushed down to the Snowflake database.- Parameters:
include_describe – Include query notifications for describe queries
include_thread_id – Include thread id where queries are called
include_error – record queries that have error during execution
>>> with session.query_history(True) as query_history: ... df = session.create_dataframe([[1, 2], [3, 4]], schema=["a", "b"]) ... df = df.filter(df.a == 1) ... res = df.collect() >>> assert len(query_history.queries) == 2 >>> assert query_history.queries[0].is_describe >>> assert not query_history.queries[1].is_describe