> For the complete documentation index, see [llms.txt](https://docs.snowkill.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snowkill.net/reference/query-plan.md).

# Query Plan

Dataclass `QueryPlan` represents information about query plan returned by Snowflake REST API.

It is very similar to information you may see on [query profile](https://docs.snowflake.com/en/user-guide/ui-query-profile) page in SnowSight.

* **get\_running\_step()** - method which returns query step which is currently running
* **steps** (List\[QueryPlanStep])
  * **step** (int) - sequential number of step
  * **description** (str)
  * **duration** (float) - duration of step execution so far, in seconds
  * **state** (str) - internal state of step, different from query `status` and `state`
  * **nodes** (List\[QueryPlanNode])
    * **id** (int) - internal ID of node
    * **logical\_id** (int) - another ID of node, normally can be ignored
    * **name** (str) - node type, e.g. `CartesianJoin`
    * **title** (str) - additional title added to some node types
    * **labels** (Dict\[str, QueryPlanLabel]) - labels specific for this node
      * **name** (str) - label name
      * **value** (Any) - label value, can be single value or List
    * **waits** (Dict\[str, QueryPlanWait) - waits specific for this node
      * **name** (str)
      * **value** (float)
      * **percentage** (float)
    * **statistics\_io** (Dict\[str, QueryPlanStatistics]) - IO stats for specific node
      * **name** (str) - name of statistics
      * **value** (float) - value of statistics
      * **unit** (str) - unit of statistics (e.g. `Bytes`)
    * **statistics\_pruning** (Dict\[str, QueryPlanStatistics]) - pruning stats for specific node
      * **name** (str) - name of statistics
      * **value** (float) - value of statistics
      * **unit** (str) - unit of statistics (e.g. `Bytes`)
  * **edges** (List\[QueryPlanEdge]) - edges represent connection between graph nodes
    * **id** (str) - ID of edge
    * **src** (int) - ID of source node
    * **dst** (int) - ID of destination node
    * **rows** (int) - number of rows passed from source node to destination node so far
    * **expression** (Any)
  * **labels** (Dict\[str, QueryPlanLabel]) - labels specific for the whole query step
    * **name** (str) - label name
    * **value** (Any) - label value, can be single value or List
  * **waits** (Dict\[str, QueryPlanWait) - waits specific for the whole query step
    * **name** (str)
    * **value** (float)
    * **percentage** (float)
  * **statistics\_io** (Dict\[str, QueryPlanStatistics]) - IO stats for the whole query step
    * **name** (str) - name of statistics
    * **value** (float) - value of statistics
    * **unit** (str) - unit of statistics (e.g. `Bytes`)
  * **statistics\_pruning** (Dict\[str, QueryPlanStatistics]) - pruning stats for the whole query step
    * **name** (str) - name of statistics
    * **value** (float) - value of statistics
    * **unit** (str) - unit of statistics (e.g. `Bytes`)
  * **statistics\_spilling** (Dict\[str, QueryPlanStatistics]) - spilling stats for the whole query step
    * **name** (str) - name of statistics
    * **value** (float) - value of statistics
    * **unit** (str) - unit of statistics (e.g. `Bytes`)
  * **get\_upstream\_nodes(QueryPlanNode)** - return list of all upstream nodes for specific node
  * **get\_downstream\_nodes(QueryPlanNode)** - return list of all downstream nodes for specific node
  * **get\_rows\_between\_nodes(QueryPlanNode, QueryPlanNode)** - returns the amount of rows passed between pair of nodes, returns `None` if no rows were passed
