presto-main/src/main/java/io/prestosql/sql/planner/iterative/rule/EliminateCrossJoins.java/EliminateCrossJoins/apply
class EliminateCrossJoins:    @Override
    public Result apply(JoinNode node, Captures captures, Context context)
    {
        JoinGraph joinGraph = JoinGraph.buildFrom(metadata, node, context.getLookup(), context.getIdAllocator());
        if (joinGraph.size() < 3 || !joinGraph.isContainsCrossJoin()) {
            return Result.empty();
        }

        List<Integer> joinOrder = getJoinOrder(joinGraph);
        if (isOriginalOrder(joinOrder)) {
            return Result.empty();
        }

        PlanNode replacement = buildJoinTree(node.getOutputSymbols(), joinGraph, joinOrder, context.getIdAllocator());
        return Result.ofPlanNode(replacement);
    }