re20052 commented on code in PR #66187:
URL: https://github.com/apache/doris/pull/66187#discussion_r4610860686


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindRelation.java:
##########
@@ -800,6 +806,18 @@ private boolean 
isScanAppendOnlyTableStream(OlapTableStream table) {
 
     private LogicalPlan getLogicalPlan(TableIf table, UnboundRelation 
unboundRelation,
                                        List<String> qualifiedTableName, 
CascadesContext cascadesContext) {
+        if (unboundRelation.isMaxVisiblePartition()) {
+            TableIf.TableType type = table.getType();
+            if (type != TableIf.TableType.OLAP && type != 
TableIf.TableType.MATERIALIZED_VIEW) {
+                throw new AnalysisException("max_visible_partition() is only 
supported on OLAP table "
+                        + "or materialized view, but table " + table.getName() 
+ " is " + type);
+            }
+            if (unboundRelation.getTableSnapshot().isPresent()) {
+                throw new AnalysisException("max_visible_partition() cannot be 
used with FOR VERSION/TIME AS OF");
+            }
+            
cascadesContext.getStatementContext().setHasMaxVisiblePartition(true);

Review Comment:
   Fixed in c271bf6b2f7.
   
   The MTMV analysis now rejects max_visible_partition() based on the 
statement-level syntax flag, so the validation no longer depends on 
manuallySpecifiedPartitions being non-empty. This also covers an empty source 
where getPartitionIds() returns [].
   
   I added a regression case that creates an empty partitioned source and 
verifies that an MTMV definition containing max_visible_partition() is 
rejected. Querying an existing MTMV with the modifier remains supported.



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