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