From 3f42e6e093c52cfedf2675419941951dc5d46d96 Mon Sep 17 00:00:00 2001 From: Baymine <978176728@qq.com> Date: Fri, 27 Dec 2024 14:59:19 +0800 Subject: [PATCH] [fix](cache) enhance cache key computation by removing comments and trimming SQL input --- .../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 29be4af41a7675..20f06e59ce9172 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())