bp #35686 Co-authored-by: zhangdong <493738387@qq.com>
This commit is contained in:
@ -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;
|
||||
@ -307,6 +310,20 @@ public class ModifyTablePropertiesClause extends AlterTableClause {
|
||||
} 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
|
||||
|
||||
@ -32,6 +32,7 @@ import org.apache.doris.catalog.DistributionInfo;
|
||||
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;
|
||||
@ -502,6 +503,7 @@ public class DynamicPartitionScheduler extends MasterDaemon {
|
||||
olapTable = (OlapTable) db.getTableNullable(tableId);
|
||||
// Only OlapTable has DynamicPartitionProperty
|
||||
if (olapTable == null
|
||||
|| olapTable instanceof MTMV
|
||||
|| !olapTable.dynamicPartitionExists()
|
||||
|| !olapTable.getTableProperty().getDynamicPartitionProperty().getEnable()) {
|
||||
iterator.remove();
|
||||
|
||||
@ -33,6 +33,7 @@ import org.apache.doris.catalog.TableIf;
|
||||
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;
|
||||
@ -178,6 +179,9 @@ public class CreateMTMVInfo {
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
@ -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 """
|
||||
|
||||
@ -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};"""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user