public RelNode trim(RelBuilder relBuilder, RelNode root,
      ColumnAccessInfo columnAccessInfo, Map<HiveProject, Table> viewToTableSchema) {
    try {
      // Set local thread variables
      COLUMN_ACCESS_INFO.set(columnAccessInfo);
      VIEW_PROJECT_TO_TABLE_SCHEMA.set(viewToTableSchema);
      // Execute pruning
      return super.trim(relBuilder, root);
    } finally {
      // Always remove the local thread variables to avoid leaks
      COLUMN_ACCESS_INFO.remove();
      VIEW_PROJECT_TO_TABLE_SCHEMA.remove();
    }
  }
Trims unused fields from a relational expression.

<p>We presume that all fields of the relational expression are wanted by
its consumer, so only trim fields that are not used within the tree.

@param root Root node of relational expression
@return Trimmed relational expression
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveRelFieldTrimmer.java