snowflake.snowpark.Session.query_historyΒΆ

Session.query_history(include_describe: bool = False, include_thread_id: bool = False) β†’ QueryHistory[source]ΒΆ

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

>>> 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
Copy