Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,8 @@ public enum SQLVisitorRule {

CREATE_MATERIALIZED_VIEW_LOG("CreateMaterializedViewLog", SQLStatementType.DDL),

DORIS_REFRESH_MATERIALIZED_VIEW("RefreshMaterializedView", SQLStatementType.DDL),

CREATE_OPERATOR("CreateOperator", SQLStatementType.DDL),

CREATE_INDEX_TYPE("CreateIndexType", SQLStatementType.DDL),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,18 @@ refreshSchedule
;
// DORIS ADDED END

// DORIS ADDED BEGIN
refreshMaterializedView
: REFRESH MATERIALIZED VIEW name (partitionSpec | refreshMethod)
;
// DORIS ADDED END

// DORIS ADDED BEGIN
partitionSpec
: PARTITIONS LP_ identifierList RP_
;
// DORIS ADDED END

alterView
: ALTER (ALGORITHM EQ_ (UNDEFINED | MERGE | TEMPTABLE))?
ownerStatement?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ execute
| delimiter
| startReplica
| createMaterializedView
| refreshMaterializedView
| resumeJob
| pauseJob
| dropJob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CreateLikeClauseContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CreateLogfileGroupContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CreateMaterializedViewContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.RefreshMaterializedViewContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CreateProcedureContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CreateServerContext;
import org.apache.shardingsphere.sql.parser.autogen.DorisStatementParser.CreateSyncJobContext;
Expand Down Expand Up @@ -291,6 +292,7 @@
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisResumeJobStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisResumeSyncJobStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisStopSyncJobStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisRefreshMaterializedViewStatement;
import org.apache.shardingsphere.sql.parser.statement.mysql.ddl.event.MySQLAlterEventStatement;
import org.apache.shardingsphere.sql.parser.statement.mysql.ddl.event.MySQLCreateEventStatement;
import org.apache.shardingsphere.sql.parser.statement.mysql.ddl.event.MySQLDropEventStatement;
Expand Down Expand Up @@ -2037,6 +2039,19 @@ public ASTNode visitCreateMaterializedView(final CreateMaterializedViewContext c
return new CreateMaterializedViewStatement(getDatabaseType());
}

@Override
public ASTNode visitRefreshMaterializedView(final RefreshMaterializedViewContext ctx) {
boolean auto = null != ctx.refreshMethod() && null != ctx.refreshMethod().AUTO();
boolean complete = null != ctx.refreshMethod() && null != ctx.refreshMethod().COMPLETE();
List<String> partitionNames = new LinkedList<>();
if (null != ctx.partitionSpec()) {
for (IdentifierContext each : ctx.partitionSpec().identifierList().identifier()) {
partitionNames.add(((IdentifierValue) visit(each)).getValue());
}
}
return new DorisRefreshMaterializedViewStatement(getDatabaseType(), ((IdentifierValue) visit(ctx.name().identifier())).getValue(), auto, complete, partitionNames);
}

@Override
public ASTNode visitCreateEncryptKey(final CreateEncryptKeyContext ctx) {
return new CreateEncryptKeyStatement(getDatabaseType());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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 lombok.Getter;
import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
import org.apache.shardingsphere.sql.parser.statement.core.statement.type.ddl.DDLStatement;

import java.util.List;

/**
* Refresh materialized view statement for Doris.
*/
@Getter
public final class DorisRefreshMaterializedViewStatement extends DDLStatement {

private final String mvName;

private final boolean auto;

private final boolean complete;

private final List<String> partitionNames;

public DorisRefreshMaterializedViewStatement(final DatabaseType databaseType, final String mvName, final boolean auto, final boolean complete, final List<String> partitionNames) {
super(databaseType);
this.mvName = mvName;
this.auto = auto;
this.complete = complete;
this.partitionNames = partitionNames;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisCreateFunctionStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisDropFunctionStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisCancelMaterializedViewTaskStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisRefreshMaterializedViewStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisCancelTaskStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisAlterJobStatement;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisDropJobStatement;
Expand All @@ -41,13 +42,15 @@
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.dialect.doris.type.DorisAlterColocateGroupStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.dialect.doris.type.DorisAlterStoragePolicyStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.dialect.doris.type.DorisAlterWorkloadGroupStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.statement.ddl.dialect.doris.type.DorisRefreshMaterializedViewStatementAssert;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisAlterColocateGroupStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisAlterStoragePolicyStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisAlterWorkloadGroupStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisCreateJobStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisDropFunctionStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisCancelMaterializedViewTaskStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisRefreshMaterializedViewStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisCancelTaskStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisAlterJobStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisDropJobStatementTestCase;
Expand Down Expand Up @@ -108,6 +111,8 @@ public static void assertIs(final SQLCaseAssertContext assertContext, final DDLS
DorisCancelTaskStatementAssert.assertIs(assertContext, (DorisCancelTaskStatement) actual, (DorisCancelTaskStatementTestCase) expected);
} else if (actual instanceof DorisCancelMaterializedViewTaskStatement) {
DorisCancelMaterializedViewTaskStatementAssert.assertIs(assertContext, (DorisCancelMaterializedViewTaskStatement) actual, (DorisCancelMaterializedViewTaskStatementTestCase) expected);
} else if (actual instanceof DorisRefreshMaterializedViewStatement) {
DorisRefreshMaterializedViewStatementAssert.assertIs(assertContext, (DorisRefreshMaterializedViewStatement) actual, (DorisRefreshMaterializedViewStatementTestCase) expected);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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.test.it.sql.parser.internal.asserts.statement.ddl.dialect.doris.type;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.sql.parser.statement.doris.ddl.DorisRefreshMaterializedViewStatement;
import org.apache.shardingsphere.test.it.sql.parser.internal.asserts.SQLCaseAssertContext;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisRefreshMaterializedViewStatementTestCase;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Refresh materialized view statement assert for Doris.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class DorisRefreshMaterializedViewStatementAssert {

/**
* Assert refresh materialized view statement is correct with expected parser result.
*
* @param assertContext assert context
* @param actual actual refresh materialized view statement
* @param expected expected refresh materialized view statement test case
*/
public static void assertIs(final SQLCaseAssertContext assertContext, final DorisRefreshMaterializedViewStatement actual, final DorisRefreshMaterializedViewStatementTestCase expected) {
if (null != expected.getMvName()) {
assertThat(assertContext.getText("materialized view name does not match: "), actual.getMvName(), is(expected.getMvName()));
}
if (expected.isAuto()) {
assertTrue(actual.isAuto(), assertContext.getText("materialized view refresh type AUTO does not match: "));
}
if (expected.isComplete()) {
assertTrue(actual.isComplete(), assertContext.getText("materialized view refresh type COMPLETE does not match: "));
}
if (!expected.getPartitionNames().isEmpty()) {
assertThat(assertContext.getText("materialized view partition names do not match: "), actual.getPartitionNames(), is(expected.getPartitionNames()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisCreateJobStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisCreateStreamingJobStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisCreateSyncJobStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisRefreshMaterializedViewStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisDropFunctionStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisDropJobStatementTestCase;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris.DorisPauseJobStatementTestCase;
Expand Down Expand Up @@ -651,6 +652,9 @@ public final class RootSQLParserTestCases {
@XmlElement(name = "create-streaming-job")
private final List<DorisCreateStreamingJobStatementTestCase> createStreamingJobTestCases = new LinkedList<>();

@XmlElement(name = "doris-refresh-materialized-view")
private final List<DorisRefreshMaterializedViewStatementTestCase> dorisRefreshMaterializedViewTestCases = new LinkedList<>();

@XmlElement(name = "alter-catalog")
private final List<AlterCatalogStatementTestCase> alterCatalogTestCases = new LinkedList<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.test.it.sql.parser.internal.cases.parser.jaxb.statement.ddl.dialect.doris;

import lombok.Getter;
import lombok.Setter;
import org.apache.shardingsphere.test.it.sql.parser.internal.cases.parser.jaxb.SQLParserTestCase;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import java.util.LinkedList;
import java.util.List;

/**
* Refresh materialized view statement test case for Doris.
*/
@XmlAccessorType(XmlAccessType.FIELD)
@Getter
@Setter
public final class DorisRefreshMaterializedViewStatementTestCase extends SQLParserTestCase {

@XmlElement(name = "mv-name")
private String mvName;

private boolean auto;

private boolean complete;

@XmlElement(name = "partition-name")
private final List<String> partitionNames = new LinkedList<>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,17 @@
<refresh-materialized-view sql-case-id="refresh_mat_view_concurrently_no_data" />
<refresh-materialized-view sql-case-id="refresh_mat_view_point" />
<refresh-materialized-view sql-case-id="refresh_mat_view" />
<doris-refresh-materialized-view sql-case-id="doris_refresh_materialized_view_auto">
<mv-name>mv1</mv-name>
<auto>true</auto>
</doris-refresh-materialized-view>
<doris-refresh-materialized-view sql-case-id="doris_refresh_materialized_view_partitions">
<mv-name>mv1</mv-name>
<partition-name>p_19950801_19950901</partition-name>
<partition-name>p_19950901_19951001</partition-name>
</doris-refresh-materialized-view>
<doris-refresh-materialized-view sql-case-id="doris_refresh_materialized_view_complete">
<mv-name>mv1</mv-name>
<complete>true</complete>
</doris-refresh-materialized-view>
</sql-parser-test-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@
<sql-case id="refresh_mat_view_concurrently_no_data" value="REFRESH MATERIALIZED VIEW CONCURRENTLY mvtest_tvmm WITH NO DATA;" db-types="PostgreSQL" />
<sql-case id="refresh_mat_view_point" value="REFRESH MATERIALIZED VIEW matview_schema.mv_nodata2;" db-types="PostgreSQL" />
<sql-case id="refresh_mat_view" value="REFRESH MATERIALIZED VIEW mvtest_mv;" db-types="PostgreSQL" />
<sql-case id="doris_refresh_materialized_view_auto" value="REFRESH MATERIALIZED VIEW mv1 AUTO" db-types="Doris" />
<sql-case id="doris_refresh_materialized_view_partitions" value="REFRESH MATERIALIZED VIEW mv1 partitions(p_19950801_19950901,p_19950901_19951001)" db-types="Doris" />
<sql-case id="doris_refresh_materialized_view_complete" value="REFRESH MATERIALIZED VIEW mv1 complete" db-types="Doris" />
</sql-cases>
Loading