class_docstr: Removes unnecessary columns in the SELECT clauses.
class_docstr_tok: ["Removes","unnecessary","columns","in","the","SELECT","clauses","."]
code: def optimize(
      self, node: SqlQueryPlanNode
  ) -> SqlQueryPlanNode:  # noqa: D
      # Can't prune columns without knowing the structure of the query.
      if not node.as_select_node:
          return node
  
      pruning_visitor = SqlColumnPrunerVisitor(
          required_column_aliases={
              x.column_alias for x in node.as_select_node.select_columns
          }
      )
  
      return node.accept(pruning_visitor)
  
file_path: metricflow/metricflow/sql/optimizer/column_pruner.py
imports: from __future__ import annotations
  import logging
  from collections import defaultdict
  from typing import Dict, List, Set, Tuple
  from metricflow.sql.optimizer.sql_query_plan_optimizer import SqlQueryPlanOptimizer
  from metricflow.sql.sql_exprs import SqlExpressionTreeLineage
  from metricflow.sql.sql_plan import SqlJoinDescription, SqlQueryPlanNode, SqlQueryPlanNodeVisitor, SqlSelectColumn, SqlSelectQueryFromClauseNode, SqlSelectStatementNode, SqlTableFromClauseNode
label_desc: Use image node_id 1 for calling the SqlColumnPrunerOptimizer obj's underlying member method code with example usage: obj.optimize(node) and returns: node, node