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

   ### What problem does this PR solve?
   
   Issue Number: close #69367
   
   Problem Summary:
   
   `CREATE MATERIALIZED VIEW IF NOT EXISTS` was accepted by the parser for 
synchronous materialized views, but the flag was never propagated to 
`CreateMaterializedViewCommand`, so it was silently ignored. Creating an 
already existing sync MV therefore failed:
   
   - same query: `Duplicate column name 'mv_k1'`
   - different query: `Materialized view[mv1] already exists`
   
   Async materialized views and `CREATE TABLE IF NOT EXISTS` already no-op in 
this case.
   
   This change propagates the flag and, under the base table write lock, 
returns without creating a job when the materialized view index already exists. 
The existence check is placed before the full-schema column check so the no-op 
path does not hit the duplicate-column error. A plain `CREATE MATERIALIZED 
VIEW` keeps the previous behavior.
   
   ### Release note
   
   `CREATE MATERIALIZED VIEW IF NOT EXISTS` now works for synchronous 
materialized views and does nothing when the view already exists.
   
   ### Check List (For Author)
   
   - Test: Regression test / Unit Test
       - Regression: `mv_p0/test_create_mv_if_not_exists`, 
`mv_p0/test_create_mv`
       - Unit: `NereidsParserTest#testCreateSyncMvIfNotExists`
   - Behavior changed: Yes. `CREATE MATERIALIZED VIEW IF NOT EXISTS` on an 
existing synchronous materialized view now succeeds instead of raising an error.
   - Does this need documentation: Yes. The synchronous materialized view 
`CREATE MATERIALIZED VIEW` syntax page can document the optional `IF NOT 
EXISTS` clause.
   


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