yujun777 commented on code in PR #70289:
URL: https://github.com/apache/doris/pull/70289#discussion_r4664319663


##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPlanUtil.java:
##########
@@ -567,8 +565,9 @@ public static MTMVAnalyzeQueryInfo analyzeQueryWithSql(MTMV 
mtmv, ConnectContext
         
mtmvPartitionDefinition.setPartitionType(mvPartitionInfo.getPartitionType());
         Expr expr = mvPartitionInfo.getExpr();
         if (expr != null) {
+            // The stored expression references base-table columns; reanalysis 
starts from MV output columns.
             mtmvPartitionDefinition.setFunctionCallExpression(new 
NereidsParser().parseExpression(
-                    expr.accept(ExprToSqlVisitor.INSTANCE, 
ToSqlParams.WITH_TABLE)));
+                    
MTMVPartitionExprFactory.getExprService(expr).toSql(mvPartitionInfo)));

Review Comment:
   Fixed in e20769688e2. Identical WEEK/WEEK and QUARTER/QUARTER truncations 
now merge; the existing restrictions for different calendar units remain in 
place. Added schema-change reanalysis cases for both units, with and without 
the original date column in the output, plus mixed-case same-unit expression 
tests. The four focused FE test classes pass all 93 tests, including the 
existing mixed-unit and partition-lineage coverage.
   



##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPlanUtil.java:
##########
@@ -567,8 +565,9 @@ public static MTMVAnalyzeQueryInfo analyzeQueryWithSql(MTMV 
mtmv, ConnectContext
         
mtmvPartitionDefinition.setPartitionType(mvPartitionInfo.getPartitionType());
         Expr expr = mvPartitionInfo.getExpr();
         if (expr != null) {
+            // The stored expression references base-table columns; reanalysis 
starts from MV output columns.
             mtmvPartitionDefinition.setFunctionCallExpression(new 
NereidsParser().parseExpression(
-                    expr.accept(ExprToSqlVisitor.INSTANCE, 
ToSqlParams.WITH_TABLE)));
+                    
MTMVPartitionExprFactory.getExprService(expr).toSql(mvPartitionInfo)));

Review Comment:
   Addressed the reconstruction in e20769688e2: MTMVPartitionDefinition now 
uses raw identifier parts rather than UnboundSlot.getName(), so SQL quoting is 
not included in output-name matching. Planner-level tests cover q.day and a 
name containing both a dot and a backtick.
   
   I also checked the full CREATE example. On this branch it encounters a 
separate pre-existing physical partition-description conversion failure before 
refresh, so the tests isolate the partition-definition reconstruction and this 
PR does not claim to fix that physical CREATE path. All 93 focused FE tests 
pass.
   



##########
fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVPlanUtil.java:
##########
@@ -567,8 +565,9 @@ public static MTMVAnalyzeQueryInfo analyzeQueryWithSql(MTMV 
mtmv, ConnectContext
         
mtmvPartitionDefinition.setPartitionType(mvPartitionInfo.getPartitionType());
         Expr expr = mvPartitionInfo.getExpr();
         if (expr != null) {
+            // The stored expression references base-table columns; reanalysis 
starts from MV output columns.
             mtmvPartitionDefinition.setFunctionCallExpression(new 
NereidsParser().parseExpression(
-                    expr.accept(ExprToSqlVisitor.INSTANCE, 
ToSqlParams.WITH_TABLE)));
+                    
MTMVPartitionExprFactory.getExprService(expr).toSql(mvPartitionInfo)));

Review Comment:
   Fixed in e20769688e2 by using SqlUtils.getIdentSql() in the shared 
date-trunc renderer, which doubles embedded backticks before reparsing. Added 
VARCHAR-widening/reanalysis cases for q`day both with and without the raw date 
column in the output, as well as planner-level coverage combining a dot and an 
embedded backtick. All 93 focused FE tests pass; the shared renderer also fixes 
escaping in SHOW CREATE.
   



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

Reply via email to