924060929 commented on code in PR #49341:
URL: https://github.com/apache/doris/pull/49341#discussion_r2084286954


##########
fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java:
##########
@@ -945,57 +945,65 @@ private static ImmutableSortedMap.Builder<String, 
VarContext> getStringVarContex
 
     public static void forceUpdateVariables() {
         int currentVariableVersion = GlobalVariable.variableVersion;
+        String updateInfo = currentVariableVersion + "to" + 
GlobalVariable.CURRENT_VARIABLE_VERSION;
         if (currentVariableVersion == GlobalVariable.VARIABLE_VERSION_0) {
             // update from 2.0.15 or below to 2.0.16 or higher
             if (VariableMgr.newSessionVariable().nereidsTimeoutSecond == 5) {
-                VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+                VariableMgr.refreshDefaultSessionVariables(updateInfo,
                         SessionVariable.NEREIDS_TIMEOUT_SECOND, "30");
             }
         }
         if (currentVariableVersion < GlobalVariable.VARIABLE_VERSION_100) {
             // update from 2.1.6 or below to 2.1.7 or higher
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_NEREIDS_DML,
                     String.valueOf(true));
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_NEREIDS_DML_WITH_PIPELINE,
                     String.valueOf(true));
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_NEREIDS_PLANNER,
                     String.valueOf(true));
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_FALLBACK_TO_ORIGINAL_PLANNER,
                     String.valueOf(true));
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_PIPELINE_X_ENGINE,
                     String.valueOf(true));
         }
         if (currentVariableVersion < GlobalVariable.VARIABLE_VERSION_101) {
             if (StatisticsUtil.getAutoAnalyzeTableWidthThreshold()
                     < StatisticConstants.AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD) {
-                VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+                VariableMgr.refreshDefaultSessionVariables(updateInfo,
                         SessionVariable.AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD,
                         
String.valueOf(StatisticConstants.AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD));
             }
             if (StatisticsUtil.getTableStatsHealthThreshold()
                     < StatisticConstants.TABLE_STATS_HEALTH_THRESHOLD) {
-                VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+                VariableMgr.refreshDefaultSessionVariables(updateInfo,
                         SessionVariable.TABLE_STATS_HEALTH_THRESHOLD,
                         
String.valueOf(StatisticConstants.TABLE_STATS_HEALTH_THRESHOLD));
             }
         }
         if (currentVariableVersion < GlobalVariable.VARIABLE_VERSION_200) {
             // update from 3.0.2 or below to 3.0.3 or higher
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_FALLBACK_TO_ORIGINAL_PLANNER,
                     String.valueOf(false));
         }
         if (currentVariableVersion < GlobalVariable.VARIABLE_VERSION_300) {
             // update to master
-            // do nothing
+            long sqlMode = defaultSessionVariable.sqlMode;
+            if ((sqlMode & SqlModeHelper.MODE_DEFAULT) != 0) {
+                sqlMode ^= SqlModeHelper.MODE_DEFAULT;
+            }

Review Comment:
   what the function in this branch? remove the first bit?



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindExpression.java:
##########
@@ -387,7 +392,40 @@ private LogicalHaving<Plan> 
bindHaving(MatchingContext<LogicalHaving<Plan>> ctx)
         Supplier<Scope> childChildrenOutput = Suppliers.memoize(() ->
                 toScope(cascadesContext, 
PlanUtils.fastGetChildrenOutputs(childPlan.children()))
         );
-        return bindHavingByScopes(having, cascadesContext, childOutput, 
childChildrenOutput);
+        LogicalHaving<Plan> boundHaving = bindHavingByScopes(having, 
having.child(),
+                cascadesContext, childOutput, childChildrenOutput);
+        if (!SqlModeHelper.hasOnlyFullGroupBy() && childPlan instanceof 
LogicalProject) {
+            // ATTN, process having(project) that have aggregate function in 
having
+            LogicalProject<?> project = (LogicalProject<?>) childPlan;
+            List<AggregateFunction> aggFuncs = 
CollectNonWindowedAggFuncs.collect(boundHaving.getConjuncts());
+            if (!aggFuncs.isEmpty()) {
+                Map<Expression, Expression> replaceMap = Maps.newHashMap();
+                for (AggregateFunction aggFunc : aggFuncs) {
+                    // ATTN: this is a little trick here. since replace check 
replace successful with equal operator
+                    //  here, we generate a new aggFunc to replace to avoid 
rewrite its child.
+                    //  because we do not want to replace agg func agg(child) 
to agg(any_value(child))
+                    replaceMap.put(aggFunc, 
aggFunc.withChildren(aggFunc.children()));

Review Comment:
   where is the check which use `==`, please add the comment



##########
fe/fe-core/src/main/java/org/apache/doris/qe/VariableMgr.java:
##########
@@ -945,57 +945,65 @@ private static ImmutableSortedMap.Builder<String, 
VarContext> getStringVarContex
 
     public static void forceUpdateVariables() {
         int currentVariableVersion = GlobalVariable.variableVersion;
+        String updateInfo = currentVariableVersion + "to" + 
GlobalVariable.CURRENT_VARIABLE_VERSION;
         if (currentVariableVersion == GlobalVariable.VARIABLE_VERSION_0) {
             // update from 2.0.15 or below to 2.0.16 or higher
             if (VariableMgr.newSessionVariable().nereidsTimeoutSecond == 5) {
-                VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+                VariableMgr.refreshDefaultSessionVariables(updateInfo,
                         SessionVariable.NEREIDS_TIMEOUT_SECOND, "30");
             }
         }
         if (currentVariableVersion < GlobalVariable.VARIABLE_VERSION_100) {
             // update from 2.1.6 or below to 2.1.7 or higher
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_NEREIDS_DML,
                     String.valueOf(true));
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_NEREIDS_DML_WITH_PIPELINE,
                     String.valueOf(true));
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_NEREIDS_PLANNER,
                     String.valueOf(true));
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_FALLBACK_TO_ORIGINAL_PLANNER,
                     String.valueOf(true));
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_PIPELINE_X_ENGINE,
                     String.valueOf(true));
         }
         if (currentVariableVersion < GlobalVariable.VARIABLE_VERSION_101) {
             if (StatisticsUtil.getAutoAnalyzeTableWidthThreshold()
                     < StatisticConstants.AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD) {
-                VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+                VariableMgr.refreshDefaultSessionVariables(updateInfo,
                         SessionVariable.AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD,
                         
String.valueOf(StatisticConstants.AUTO_ANALYZE_TABLE_WIDTH_THRESHOLD));
             }
             if (StatisticsUtil.getTableStatsHealthThreshold()
                     < StatisticConstants.TABLE_STATS_HEALTH_THRESHOLD) {
-                VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+                VariableMgr.refreshDefaultSessionVariables(updateInfo,
                         SessionVariable.TABLE_STATS_HEALTH_THRESHOLD,
                         
String.valueOf(StatisticConstants.TABLE_STATS_HEALTH_THRESHOLD));
             }
         }
         if (currentVariableVersion < GlobalVariable.VARIABLE_VERSION_200) {
             // update from 3.0.2 or below to 3.0.3 or higher
-            VariableMgr.refreshDefaultSessionVariables("update variable 
version",
+            VariableMgr.refreshDefaultSessionVariables(updateInfo,
                     SessionVariable.ENABLE_FALLBACK_TO_ORIGINAL_PLANNER,
                     String.valueOf(false));
         }
         if (currentVariableVersion < GlobalVariable.VARIABLE_VERSION_300) {
             // update to master
-            // do nothing
+            long sqlMode = defaultSessionVariable.sqlMode;
+            if ((sqlMode & SqlModeHelper.MODE_DEFAULT) != 0) {
+                sqlMode ^= SqlModeHelper.MODE_DEFAULT;
+            }

Review Comment:
   what is the function in this branch? remove the first bit?



-- 
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