morrySnow commented on code in PR #33630:
URL: https://github.com/apache/doris/pull/33630#discussion_r1565117424


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/StmtRewriter.java:
##########
@@ -1365,4 +1370,116 @@ public static boolean rewriteByPolicy(StatementBase 
statementBase, Analyzer anal
         }
         return reAnalyze;
     }
+
+    /**
+     *
+     * @param ref the SlotRef to rewrite
+     * @param selectList new selectList for selectStmt
+     * @param groupByExprs group by Exprs for selectStmt
+     * @return true if ref can be rewritten
+     */
+    private static boolean rewriteSelectList(SlotRef ref, SelectList 
selectList, ArrayList<Expr> groupByExprs,
+                                             ArrayList<FunctionCallExpr> 
aggExprs) {
+        Column column = ref.getColumn();
+        if (column.isKey()) {
+            selectList.addItem(new SelectListItem(ref, null));
+            groupByExprs.add(ref);
+            return true;
+        } else {
+            AggregateType aggregateType = column.getAggregationType();
+            if (aggregateType != AggregateType.SUM && aggregateType != 
AggregateType.MAX
+                    && aggregateType != AggregateType.MIN) {
+                return false;
+            } else {
+                FunctionName funcName = new 
FunctionName(aggregateType.toString().toLowerCase());
+                List<Expr> arrayList = Lists.newArrayList(ref);
+                FunctionCallExpr func =  new FunctionCallExpr(funcName, new 
FunctionParams(false, arrayList));
+                selectList.addItem(new SelectListItem(func, null));
+                aggExprs.add(func);
+                return true;
+            }
+        }
+    }
+
+    public static boolean rewriteForRandomDistribution(StatementBase 
statementBase, Analyzer analyzer)

Review Comment:
   add comment to explain this function



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to