englefly opened a new pull request, #69787:
URL: https://github.com/apache/doris/pull/69787

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Problem Summary:
   
   The materialized view rewrite keeps a query output which is a **constant** 
as it is, because the view does not
   have to output that column, but it only recognized a bare `Literal`. A 
constant alias such as
   `1 AS o_orderkey#97` (the shape constant propagation materializes above an 
aggregate) or a constant function
   such as `bin(1)` did not reach that path, so the rewrite looked for a 
counterpart in the view, did not find it,
   and rejected the candidate. The explain then reports `... not chose` and the 
query does not use the view even
   though the columns are pinned by predicates.
   
   Accept every constant expression there (`isConstant()` covers `Literal` and 
constant aliases/functions) so a
   constant query output needs no counterpart in the view. Aggregate functions 
over literals (`count(1)`) are not
   constant by definition and keep the previous behavior.
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test:
       - Unit Test: the materialized view unit tests (`MappingTest`, 
`MaterializedViewUtilsTest`,
         `MvExplorationSuiteTest`, `AsyncMaterializationContextTest`, 
`PartitionColumnTraceTest`) pass
       - Regression test: the whole `nereids_rules_p0/mv` directory. `Explain 
and check failed` does not appear:
         no materialized view rewrite case regressed. 10 suites of that 
directory fail in this local environment
         for unrelated reasons: 5 stream load failures (empty response body), 4 
external table suites which cannot
         reach a Hive metastore, and 1 outfile suite without S3 credentials.
   - Behavior changed: No
   - Does this need documentation: No
   


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