You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "jay841224 (via GitHub)" <gi...@apache.org> on 2025/03/09 14:11:34 UTC
[PR] Fix the error in parsing the Doris create materialized view [shardingsphere]
jay841224 opened a new pull request, #34943:
URL: https://github.com/apache/shardingsphere/pull/34943
Fixes #31499
Changes proposed in this pull request:
This pull request modify the parsing of the following sql:
```sql
CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE
CREATE MATERIALIZED VIEW mv1 REFRESH COMPLETE
CREATE MATERIALIZED VIEW mv1 REFRESH ON SCHEDULE EVERY 2 HOUR STARTS "2023-12-13 21:07:09"
CREATE MATERIALIZED VIEW mv1 KEY(k1,k2)
```
For the completeness of SQL syntax, I added a simple SELECT at the end to ensure they work properly.
```sql
CREATE MATERIALIZED VIEW mv1 BUILD IMMEDIATE AS SELECT k1, k2 FROM test_table;
CREATE MATERIALIZED VIEW mv1 REFRESH COMPLETE AS SELECT k1, k2 FROM test_table;
CREATE MATERIALIZED VIEW mv1 REFRESH ON SCHEDULE EVERY 2 HOUR STARTS "2023-12-13 21:07:09" AS SELECT k1, k2 FROM test_table;
CREATE MATERIALIZED VIEW mv1 KEY(k1,k2) AS SELECT k1, k2 FROM test_table;
```
Since the original Doris DDL did not have Materialized Views, I referred to [Materialized Views](https://doris.apache.org/docs/query-acceleration/materialized-view/async-materialized-view/functions-and-demands) and added parsing syntax in DDLStatement.g4.
---
Before committing this PR, I'm sure that I have checked the following options:
- [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [x] I have self-reviewed the commit code.
- [x] I have (or in comment I request) added corresponding labels for the pull request.
- [x] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [] I have made corresponding changes to the documentation.
- [x] I have added corresponding unit tests for my changes.
- [ ] I have updated the Release Notes of the current development version. For more details, see [Update Release Note](https://shardingsphere.apache.org/community/en/involved/contribute/contributor/)
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enhance parsing the Doris create materialized view [shardingsphere]
Posted by "iamhucong (via GitHub)" <gi...@apache.org>.
iamhucong commented on PR #34943:
URL: https://github.com/apache/shardingsphere/pull/34943#issuecomment-2756398239
https://shardingsphere.apache.org/community/en/involved/conduct/code/#maintenance-conduct
@jay841224 Could you mark the syntax differences from MySQL? You can refer to this document for further information.
Additionally, please update the release notes for 5.5.3-SNAPSHOT.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enhance parsing the Doris create materialized view [shardingsphere]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #34943:
URL: https://github.com/apache/shardingsphere/pull/34943#discussion_r2015441462
##########
parser/sql/dialect/doris/src/main/java/org/apache/shardingsphere/sql/parser/doris/visitor/statement/type/DorisDDLStatementVisitor.java:
##########
@@ -1046,4 +1048,9 @@ public ASTNode visitExecuteStmt(final ExecuteStmtContext ctx) {
public ASTNode visitDeallocate(final DeallocateContext ctx) {
return new DorisDeallocateStatement();
}
+
+ @Override
+ public ASTNode visitCreateMaterializedView(final CreateMaterializedViewContext ctx) {
+ return new DorisCreateMaterializedViewStatement();
Review Comment:
The method visitCreateMaterializedView currently creates and returns a new DorisCreateMaterializedViewStatement without extracting any details from the provided context. If specific properties are expected from the SQL context, consider processing ctx to initialize the statement accordingly.
```suggestion
String viewName = ctx.viewName().getText();
SelectStatement selectStatement = (SelectStatement) visit(ctx.selectStatement());
return new DorisCreateMaterializedViewStatement(viewName, selectStatement);
```
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enhance parsing the Doris create materialized view [shardingsphere]
Posted by "jay841224 (via GitHub)" <gi...@apache.org>.
jay841224 commented on PR #34943:
URL: https://github.com/apache/shardingsphere/pull/34943#issuecomment-2814387484
Hi @iamhucong can you review this pr
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enhance parsing the Doris create materialized view [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu merged PR #34943:
URL: https://github.com/apache/shardingsphere/pull/34943
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enhance parsing the Doris create materialized view [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on code in PR #34943:
URL: https://github.com/apache/shardingsphere/pull/34943#discussion_r2050436337
##########
parser/sql/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4:
##########
@@ -359,6 +359,43 @@ createView
(WITH (CASCADED | LOCAL)? CHECK OPTION)?
;
+// DORIS ADDED BEGIN
+createMaterializedView
+ : CREATE MATERIALIZED VIEW ifNotExists? name
Review Comment:
Please keep the systax in one line unless it contains more than 5 branches. You can read SQL Parser of Conduct - https://shardingsphere.apache.org/community/en/involved/conduct/code/#sql-parser-of-conduct
##########
parser/sql/statement/type/doris/src/main/java/org/apache/shardingsphere/sql/parser/statement/doris/ddl/DorisCreateMaterializedViewStatement.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.sql.parser.statement.doris.ddl;
+
+import org.apache.shardingsphere.sql.parser.statement.core.statement.ddl.CreateMaterializedViewStatement;
+import org.apache.shardingsphere.sql.parser.statement.doris.DorisStatement;
+
+/**
+ * DorisSQL create materialized view statement.
+ */
+public class DorisCreateMaterializedViewStatement extends CreateMaterializedViewStatement implements DorisStatement {
Review Comment:
Please add final for DorisCreateMaterializedViewStatement.
##########
parser/sql/dialect/doris/src/main/antlr4/imports/doris/DDLStatement.g4:
##########
@@ -359,6 +359,43 @@ createView
(WITH (CASCADED | LOCAL)? CHECK OPTION)?
;
+// DORIS ADDED BEGIN
+createMaterializedView
+ : CREATE MATERIALIZED VIEW ifNotExists? name
+ (LP_ columnDefinition RP_)? buildMode?
+ (REFRESH refreshMethod? refreshTrigger?)?
+ ((DUPLICATE)? KEY keys= LP_ identifierList RP_)?
+ commentClause? partitionClause? distributedbyClause? propertiesClause?
+ AS select
+ ;
+// DORIS ADDED END
+
+// DORIS ADDED BEGIN
+buildMode
+ : BUILD (IMMEDIATE | DEFERRED)
+ ;
+// DORIS ADDED END
+
+// DORIS ADDED BEGIN
+refreshMethod
+ : COMPLETE | AUTO
+ ;
+// DORIS ADDED END
+
+// DORIS ADDED BEGIN
+refreshTrigger
+ : ON MANUAL
Review Comment:
Please keep the systax in one line unless it contains more than 5 branches. You can read SQL Parser of Conduct - https://shardingsphere.apache.org/community/en/involved/conduct/code/#sql-parser-of-conduct
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Enhance parsing the Doris create materialized view [shardingsphere]
Posted by "jay841224 (via GitHub)" <gi...@apache.org>.
jay841224 commented on PR #34943:
URL: https://github.com/apache/shardingsphere/pull/34943#issuecomment-2763189607
Hi @iamhucong I have mark the syntax differences from MySQL and update release notes for 5.5.3-SNAPSHOT.
--
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org