924060929 commented on code in PR #58031:
URL: https://github.com/apache/doris/pull/58031#discussion_r2583941679
##########
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java:
##########
@@ -1135,7 +1144,7 @@ public void checkQuerySlotCount(String slotCnt) {
@VariableMgr.VarAttr(name = SQL_AUTO_IS_NULL)
public boolean sqlAutoIsNull = false;
- @VariableMgr.VarAttr(name = SQL_SELECT_LIMIT, needForward = true,
affectQueryResult = true)
+ @VariableMgr.VarAttr(name = SQL_SELECT_LIMIT, needForward = true)
private long sqlSelectLimit = Long.MAX_VALUE;
Review Comment:
ditto
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContextUtil.java:
##########
@@ -94,4 +95,11 @@ public static Optional<Pair<ErrorCode, String>>
initCatalogAndDb(ConnectContext
ctx.getState().setOk();
return Optional.empty();
}
+
+ public static Map<String, String>
getAffectQueryResultSessionVariables(ConnectContext ctx) {
Review Comment:
should be `getAffectQueryResultInPlanVariables`
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ShowCreateMTMVInfo.java:
##########
@@ -47,6 +47,7 @@ public class ShowCreateMTMVInfo {
private static final ShowResultSetMetaData META_DATA =
ShowResultSetMetaData.builder()
.addColumn(new Column("Materialized View",
ScalarType.createVarchar(20)))
.addColumn(new Column("Create Materialized View",
ScalarType.createVarchar(30)))
+ .addColumn(new Column("var", ScalarType.createVarchar(10000)))
Review Comment:
Keep the same camel case
##########
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java:
##########
@@ -1008,7 +1017,7 @@ public static double getHotValueThreshold() {
// By default, the number of Limit items after OrderBy is changed from
65535 items
// before v1.2.0 (not included), to return all items by default
- @VariableMgr.VarAttr(name = DEFAULT_ORDER_BY_LIMIT, affectQueryResult =
true)
+ @VariableMgr.VarAttr(name = DEFAULT_ORDER_BY_LIMIT)
Review Comment:
should not remove it because make sql cache return wrong result
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/ExpressionBottomUpRewriter.java:
##########
@@ -73,7 +76,14 @@ private static Expression rewriteBottomUp(
Expression afterRewrite = expression;
try {
Expression beforeRewrite;
- afterRewrite = rewriteChildren(expression, context,
currentBatch, rules, listeners);
+ if (expression instanceof SessionVarGuardExpr) {
+ try (AutoCloseSessionVariable auto = new
AutoCloseSessionVariable(ConnectContext.get(),
Review Comment:
use connectContext from the `ExpressionRewriteContext context`
##########
fe/fe-core/src/main/java/org/apache/doris/qe/AutoCloseSessionVariable.java:
##########
@@ -0,0 +1,64 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.qe;
+
+import com.google.common.collect.Maps;
+
+import java.util.Map;
+
+/**
+ * Used to generate new SessionVariables based on the persisted map,
+ * and automatically restore to the previous SessionVariables after use.
+ */
+public class AutoCloseSessionVariable implements AutoCloseable {
+ private static final ConnectContext notNullContext = new ConnectContext();
+ private ConnectContext connectContext;
+ private boolean changed = false;
+ private SessionVariable previousVariable;
+ private ConnectContext previousConnectContext = notNullContext;
+
+ public AutoCloseSessionVariable(ConnectContext connectContext, Map<String,
String> affectQueryResultVariables) {
+ if (affectQueryResultVariables == null ||
affectQueryResultVariables.isEmpty()) {
+ return;
+ }
+ if (connectContext == null) {
+ previousConnectContext = null;
+ this.connectContext = new ConnectContext();
+ this.connectContext.setThreadLocalInfo();
Review Comment:
should use ThreadLocal's ConnectConext as the previousConnectContext if not
null?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]