Code review comment: no effect. If `MODE_ONLY_FULL_GROUP_BY` works, it means there exisit group by clause. This pr works as the old in this scene.

Code under review:
public LogicalPlan plan(SelectRelation queryBlock, ExpressionMapping outer) {
        OptExprBuilder builder = planFrom(queryBlock.getRelation(), cteContext);
        builder.setExpressionMapping(new ExpressionMapping(builder.getScope(), builder.getFieldMappings(), outer));

        Map<Expr, SlotRef> generatedExprToColumnRef = queryBlock.getGeneratedExprToColumnRef();
        ExpressionMapping expressionMapping = builder.getExpressionMapping();
        for (Map.Entry<Expr, SlotRef> m : generatedExprToColumnRef.entrySet()) {
            ScalarOperator scalarOperator = SqlToScalarOperatorTranslator.translate(m.getValue(),
                    builder.getExpressionMapping(), columnRefFactory);
            expressionMapping.put(m.getKey(), (ColumnRefOperator) scalarOperator);
        }

        builder = filter(builder, queryBlock.getPredicate());
        builder = aggregate(builder, queryBlock.getGroupBy(), queryBlock.getAggregate(),
                queryBlock.getGroupingSetsList(), queryBlock.getGroupingFunctionCallExprs());
        builder = filter(builder, queryBlock.getHaving());

        List<AnalyticExpr> analyticExprList = new ArrayList<>(queryBlock.getOutputAnalytic());
        analyticExprList.addAll(queryBlock.getOrderByAnalytic());
        builder = window(builder, analyticExprList);

        if (queryBlock.hasOrderByClause()) {
            if (!queryBlock.getGroupBy().isEmpty() || !queryBlock.getAggregate().isEmpty()) {
                
                List<String> outputNames = new ArrayList<>(queryBlock.getColumnOutputNames());
                for (int i = 0; i < queryBlock.getOrderSourceExpressions().size(); ++i) {
                    outputNames.add(queryBlock.getOrderSourceExpressions().get(i).toString());
                }

                builder = projectForOrder(builder,
                        Iterables.concat(queryBlock.getOutputExpression(),
                                queryBlock.getOrderSourceExpressions(),
                                queryBlock.getOrderByAnalytic()),
                        queryBlock.getOutputExprInOrderByScope(),
                        outputNames,
                        builder.getFieldMappings(),
                        queryBlock.getOrderScope(), true);

            } else {
                
                
                
                builder = projectForOrder(builder,
                        Iterables.concat(queryBlock.getOutputExpression(), queryBlock.getOrderByAnalytic()),
                        queryBlock.getOutputExprInOrderByScope(),
                        queryBlock.getColumnOutputNames(),
                        builder.getFieldMappings(),
                        queryBlock.getOrderScope(), queryBlock.isDistinct());
            }
        }

        builder = distinct(builder, queryBlock.isDistinct(), queryBlock.getOutputExpression());
        
        builder = project(builder, Iterables.concat(queryBlock.getOrderByExpressions(), queryBlock.getOutputExpression()));
        List<ColumnRefOperator> orderByColumns = Lists.newArrayList();
        builder = sort(builder, queryBlock.getOrderBy(), orderByColumns);
        builder = limit(builder, queryBlock.getLimit());

        List<ColumnRefOperator> outputColumns = computeOutputs(builder, queryBlock.getOutputExpression(), columnRefFactory);

        
        if (!orderByColumns.isEmpty() && !outputColumns.containsAll(orderByColumns)) {
            long limit = queryBlock.hasLimit() ? queryBlock.getLimit().getLimit() : -1;
            builder = project(builder, queryBlock.getOutputExpression(), limit);
        }

        return new LogicalPlan(builder, outputColumns, correlation);
    }

Line commented on: if (!queryBlock.getGroupBy().isEmpty() || !queryBlock.getAggregate().isEmpty()) {

Revised code:
public LogicalPlan plan(SelectRelation queryBlock, ExpressionMapping outer) {
        OptExprBuilder builder = planFrom(queryBlock.getRelation(), cteContext);
        builder.setExpressionMapping(new ExpressionMapping(builder.getScope(), builder.getFieldMappings(), outer));

        Map<Expr, SlotRef> generatedExprToColumnRef = queryBlock.getGeneratedExprToColumnRef();
        ExpressionMapping expressionMapping = builder.getExpressionMapping();
        for (Map.Entry<Expr, SlotRef> m : generatedExprToColumnRef.entrySet()) {
            ScalarOperator scalarOperator = SqlToScalarOperatorTranslator.translate(m.getValue(),
                    builder.getExpressionMapping(), columnRefFactory);
            expressionMapping.put(m.getKey(), (ColumnRefOperator) scalarOperator);
        }

        builder = filter(builder, queryBlock.getPredicate());
        builder = aggregate(builder, queryBlock.getGroupBy(), queryBlock.getAggregate(),
                queryBlock.getGroupingSetsList(), queryBlock.getGroupingFunctionCallExprs());
        builder = filter(builder, queryBlock.getHaving());

        List<AnalyticExpr> analyticExprList = new ArrayList<>(queryBlock.getOutputAnalytic());
        analyticExprList.addAll(queryBlock.getOrderByAnalytic());
        builder = window(builder, analyticExprList);

        if (queryBlock.hasOrderByClause()) {
            if (!queryBlock.getGroupBy().isEmpty() || !queryBlock.getAggregate().isEmpty()) {
                
                List<String> outputNames = new ArrayList<>(queryBlock.getColumnOutputNames());
                for (int i = 0; i < queryBlock.getOrderSourceExpressions().size(); ++i) {
                    outputNames.add(queryBlock.getOrderSourceExpressions().get(i).toString());
                }

                builder = projectForOrder(builder,
                        Iterables.concat(queryBlock.getOutputExpression(),
                                queryBlock.getOrderSourceExpressions(),
                                queryBlock.getOrderByAnalytic()),
                        queryBlock.getOutputExprInOrderByScope(),
                        outputNames,
                        builder.getFieldMappings(),
                        queryBlock.getOrderScope(), true);

            } else {
                
                
                
                builder = projectForOrder(builder,
                        Iterables.concat(queryBlock.getOutputExpression(), queryBlock.getOrderByAnalytic()),
                        queryBlock.getOutputExprInOrderByScope(),
                        queryBlock.getColumnOutputNames(),
                        builder.getFieldMappings(),
                        queryBlock.getOrderScope(), queryBlock.isDistinct());
            }
        }

        builder = distinct(builder, queryBlock.isDistinct(), queryBlock.getOutputExpression());
        
        builder = project(builder, Iterables.concat(queryBlock.getOrderByExpressions(), queryBlock.getOutputExpression()));
        List<ColumnRefOperator> orderByColumns = Lists.newArrayList();
        builder = sort(builder, queryBlock.getOrderBy(), orderByColumns);
        builder = limit(builder, queryBlock.getLimit());

        List<ColumnRefOperator> outputColumns = computeOutputs(builder, queryBlock.getOutputExpression(), columnRefFactory);

        
        if (!orderByColumns.isEmpty() && !outputColumns.containsAll(orderByColumns)) {
            long limit = queryBlock.hasLimit() ? queryBlock.getLimit().getLimit() : -1;
            builder = project(builder, queryBlock.getOutputExpression(), limit);
        }

        return new LogicalPlan(builder, outputColumns, correlation);
    }