private static int rowWidthCost(RelNode tree) {
    // The width cost is the width of the tree itself plus the widths
    // of its children.  Hence, skinnier rows are better when they're
    // lower in the tree since the width of a RelNode contributes to
    // the cost of each LogicalJoin that appears above that RelNode.
    int width = tree.getRowType().getFieldCount();
    if (isJoinTree(tree)) {
      Join joinRel = (Join) tree;
      width +=
              rowWidthCost(joinRel.getLeft())
                      + rowWidthCost(joinRel.getRight());
    }
    return width;
  }
Computes a cost for a join tree based on the row widths of the inputs
into the join. Joins where the inputs have the fewest number of columns
lower in the tree are better than equivalent joins where the inputs with
the larger number of columns are lower in the tree.

@param tree a tree of RelNodes

@return the cost associated with the width of the tree
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveLoptOptimizeJoinRule.java