From 52455ed6d5624d64baf1165139a5057c3403721e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:39:48 +0800 Subject: [PATCH] branch-2.1: [opt](cache) enhance cache key computation by removing comments and trimming SQL input #46099 (#46472) Cherry-picked from #46099 Co-authored-by: York Cao <52438394+Baymine@users.noreply.github.com> --- .../main/java/org/apache/doris/nereids/SqlCacheContext.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/SqlCacheContext.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/SqlCacheContext.java index 45a4c1d50d5794..364c8bcab65162 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/SqlCacheContext.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/SqlCacheContext.java @@ -26,6 +26,7 @@ import org.apache.doris.mysql.FieldInfo; import org.apache.doris.mysql.privilege.DataMaskPolicy; import org.apache.doris.mysql.privilege.RowFilterPolicy; +import org.apache.doris.nereids.parser.NereidsParser; import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.Variable; import org.apache.doris.nereids.util.Utils; @@ -349,7 +350,7 @@ public PUniqueId getOrComputeCacheKeyMd5() { /** doComputeCacheKeyMd5 */ public synchronized PUniqueId doComputeCacheKeyMd5(Set usedVariables) { - StringBuilder cacheKey = new StringBuilder(originSql); + StringBuilder cacheKey = new StringBuilder(NereidsParser.removeCommentAndTrimBlank(originSql.trim())); for (Entry entry : usedViews.entrySet()) { cacheKey.append("|") .append(entry.getKey())