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 @@ -18,7 +18,10 @@
package org.apache.doris.analysis;

import org.apache.doris.alter.AlterOpType;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.MTMV;
import org.apache.doris.catalog.ReplicaAllocation;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableProperty;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.util.DynamicPartitionUtil;
Expand Down Expand Up @@ -316,6 +319,20 @@ public void analyze(Analyzer analyzer) throws AnalysisException {
} else {
throw new AnalysisException("Unknown table property: " + properties.keySet());
}
analyzeForMTMV();
}

private void analyzeForMTMV() throws AnalysisException {
if (tableName != null) {
Table table = Env.getCurrentInternalCatalog().getDbOrAnalysisException(tableName.getDb())
.getTableOrAnalysisException(tableName.getTbl());
if (!(table instanceof MTMV)) {
return;
}
if (DynamicPartitionUtil.checkDynamicPartitionPropertiesExist(properties)) {
throw new AnalysisException("Not support dynamic partition properties on async materialized view");
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.apache.doris.catalog.DynamicPartitionProperty;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.HashDistributionInfo;
import org.apache.doris.catalog.MTMV;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Partition;
import org.apache.doris.catalog.PartitionItem;
Expand Down Expand Up @@ -508,6 +509,7 @@ private void executeDynamicPartition(Collection<Pair<Long, Long>> dynamicPartiti
olapTable = (OlapTable) db.getTableNullable(tableId);
// Only OlapTable has DynamicPartitionProperty
if (olapTable == null
|| olapTable instanceof MTMV
|| !olapTable.dynamicPartitionExists()
|| !olapTable.getTableProperty().getDynamicPartitionProperty().getEnable()) {
iterator.remove();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.doris.catalog.View;
import org.apache.doris.common.ErrorCode;
import org.apache.doris.common.FeNameFormat;
import org.apache.doris.common.util.DynamicPartitionUtil;
import org.apache.doris.mtmv.EnvInfo;
import org.apache.doris.mtmv.MTMVPartitionInfo;
import org.apache.doris.mtmv.MTMVPartitionInfo.MTMVPartitionType;
Expand Down Expand Up @@ -178,6 +179,9 @@ public void analyze(ConnectContext ctx) {
}

private void analyzeProperties() {
if (DynamicPartitionUtil.checkDynamicPartitionPropertiesExist(properties)) {
throw new AnalysisException("Not support dynamic partition properties on async materialized view");
}
for (String key : MTMVPropertyUtil.mvPropertyKeys) {
if (properties.containsKey(key)) {
MTMVPropertyUtil.analyzeProperty(key, properties.get(key));
Expand Down
6 changes: 6 additions & 0 deletions regression-test/suites/mtmv_p0/test_build_mtmv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ suite("test_build_mtmv") {
logger.info("showCreateTableResult: " + showCreateTableResult.toString())
assertTrue(showCreateTableResult.toString().contains("CREATE MATERIALIZED VIEW `multi_mv_test_create_mtmv` (\n `aa` BIGINT NULL COMMENT 'aaa',\n `bb` VARCHAR(20) NULL\n) ENGINE=MATERIALIZED_VIEW\nCOMMENT 'comment1'\nDISTRIBUTED BY RANDOM BUCKETS 2\nPROPERTIES"))

// desc
def descTableAllResult = sql """desc ${mvName} all"""
logger.info("descTableAllResult: " + descTableAllResult.toString())
assertTrue(descTableAllResult.toString().contains("${mvName}"))

// show data
def showDataResult = sql """show data"""
logger.info("showDataResult: " + showDataResult.toString())
assertTrue(showDataResult.toString().contains("${mvName}"))

// if not exist
try {
sql """
Expand Down
18 changes: 18 additions & 0 deletions regression-test/suites/mtmv_p0/test_limit_op_mtmv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,24 @@ suite("test_limit_op_mtmv") {
Assert.fail();
}

// not allow dynamic_partition
test {
sql """ALTER TABLE ${mvName} set ("dynamic_partition.enable" = "true")"""
exception "dynamic"
}
sql """drop materialized view if exists ${mvName};"""
test {
sql """
CREATE MATERIALIZED VIEW ${mvName}
BUILD DEFERRED REFRESH AUTO ON MANUAL
partition by(`k3`)
DISTRIBUTED BY RANDOM BUCKETS 2
PROPERTIES ('replication_num' = '1','dynamic_partition.enable'='true')
AS
SELECT * FROM ${tableName};
"""
exception "dynamic"
}
sql """drop table if exists `${tableName}`"""
sql """drop materialized view if exists ${mvName};"""
}