presto-main/src/main/java/io/prestosql/sql/planner/RelationPlan.java/RelationPlan/getAllFieldCount
class RelationPlan:    private static int getAllFieldCount(Scope root)
    {
        int allFieldCount = 0;
        Optional<Scope> current = Optional.of(root);
        while (current.isPresent()) {
            allFieldCount += current.get().getRelationType().getAllFieldCount();
            current = current.get().getLocalParent();
        }
        return allFieldCount;
    }