Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature](mtmv)(3)Implementing multi table materialized views #26146

Merged
merged 96 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 90 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
0e30d0d
Implementing mtmv using antlr
zddr Oct 30, 2023
be56a85
Implementing mtmv using antlr
zddr Oct 30, 2023
cb40588
add mtmvJobManager to DEPRECATED_MODULE_NAMES
zddr Oct 31, 2023
69297f2
1
zddr Oct 31, 2023
9b0de5f
1
zddr Oct 31, 2023
f9e89b2
Merge branch 'master' into mv_3
zddr Oct 31, 2023
f94def5
1
zddr Nov 1, 2023
d25e218
1
zddr Nov 2, 2023
0920f0a
1
zddr Nov 2, 2023
d541fb2
1
zddr Nov 3, 2023
e7c252d
1
zddr Nov 3, 2023
d23fa71
Merge branch 'master' into mv_3
zddr Nov 3, 2023
4aa2b3a
1
zddr Nov 3, 2023
178fb88
1
zddr Nov 3, 2023
db9b2fc
1
zddr Nov 3, 2023
bdde3d8
1
zddr Nov 7, 2023
17840e4
1
zddr Nov 7, 2023
611a16a
1
zddr Nov 7, 2023
19a023b
1
zddr Nov 8, 2023
325c6ae
1
zddr Nov 8, 2023
3ef6d77
1
zddr Nov 9, 2023
55597ee
Merge branch 'master' into mv_3
zddr Nov 14, 2023
126e052
1
zddr Nov 14, 2023
47ccf7b
1
zddr Nov 14, 2023
1ca72d8
MTMV extends Olap
zddr Nov 14, 2023
186f61f
Merge branch 'master' into mv_3
zddr Nov 14, 2023
3fe1450
- rename some method
CalvinKirs Nov 14, 2023
5523664
MTMV extends Olap
zddr Nov 14, 2023
8ff801e
Merge remote-tracking branch 'origin/mv_3' into mv_3
zddr Nov 14, 2023
d1b407f
1
zddr Nov 14, 2023
3feb2d2
1
zddr Nov 15, 2023
a1ca546
- support immediately scheduler
CalvinKirs Nov 15, 2023
912cfad
Merge remote-tracking branch 'origin/mv_3' into mv_3
CalvinKirs Nov 15, 2023
e90b063
1
zddr Nov 15, 2023
fcec02a
Support show mtmv job/jobs/tasks
CalvinKirs Nov 15, 2023
885539b
Support show mtmv tasks
CalvinKirs Nov 15, 2023
d8dd592
1
zddr Nov 15, 2023
559555f
Merge remote-tracking branch 'origin/mv_3' into mv_3
zddr Nov 15, 2023
c9a4659
used gson adapt write metadata
CalvinKirs Nov 15, 2023
1a40b42
Merge remote-tracking branch 'origin/mv_3' into mv_3
CalvinKirs Nov 15, 2023
eb45bd0
1
zddr Nov 15, 2023
abbd0f2
Merge remote-tracking branch 'origin/mv_3' into mv_3
zddr Nov 15, 2023
9b211f8
fix json field
CalvinKirs Nov 15, 2023
96e16a4
Merge remote-tracking branch 'origin/mv_3' into mv_3
CalvinKirs Nov 15, 2023
3f0eae3
1
zddr Nov 15, 2023
c48a153
Merge remote-tracking branch 'origin/mv_3' into mv_3
zddr Nov 15, 2023
88aec18
1
zddr Nov 16, 2023
086475a
1
zddr Nov 16, 2023
e4eb68b
1
zddr Nov 16, 2023
b641e56
case
zddr Nov 17, 2023
3f2599b
1
zddr Nov 19, 2023
030c325
1
zddr Nov 19, 2023
cb03cbf
1
zddr Nov 19, 2023
dbb226d
fix immediately start error
CalvinKirs Nov 19, 2023
23d4f71
Merge remote-tracking branch 'origin/mv_3' into mv_3
CalvinKirs Nov 19, 2023
1ed58e2
fix immediately start error
CalvinKirs Nov 19, 2023
2b2c0e8
1
zddr Nov 19, 2023
d114af9
1
zddr Nov 19, 2023
54f6337
1
zddr Nov 19, 2023
fcec31c
Merge branch 'mv_3' of github.com:zddr/incubator-doris into mv_3
zddr Nov 19, 2023
8d42bfd
1
zddr Nov 19, 2023
23f703d
Merge remote-tracking branch 'origin/mv_3' into mv_3
zddr Nov 19, 2023
365e6c5
1
zddr Nov 19, 2023
2a0a82c
Merge branch 'mv_3' of github.com:zddr/incubator-doris into mv_3
zddr Nov 19, 2023
69dcb0d
1
zddr Nov 19, 2023
19324b3
Merge remote-tracking branch 'origin/mv_3' into mv_3
zddr Nov 19, 2023
96a030f
fix immediately start error
CalvinKirs Nov 19, 2023
3febf3a
Merge remote-tracking branch 'origin/mv_3' into mv_3
CalvinKirs Nov 20, 2023
a878e3d
set scheduler window to 10 minus
CalvinKirs Nov 20, 2023
15513f3
add test
CalvinKirs Nov 20, 2023
5e5b885
support cancel insert job
CalvinKirs Nov 20, 2023
def85bb
resolve review's comment
CalvinKirs Nov 21, 2023
4751608
resolve review's comment
CalvinKirs Nov 21, 2023
c97a14e
1
zddr Nov 21, 2023
abb8040
Merge remote-tracking branch 'origin/mv_3' into mv_3
zddr Nov 21, 2023
fd53a74
1
zddr Nov 21, 2023
791fcd3
Fix job status convert error
CalvinKirs Nov 22, 2023
68fc3de
Merge remote-tracking branch 'origin/mv_3' into mv_3
CalvinKirs Nov 22, 2023
0afe2cc
Merge branch 'master' into mv_3
zddr Nov 22, 2023
31c5e16
Magnify the waiting time. In extreme cases, it may be on the edge of …
CalvinKirs Nov 22, 2023
d3bb233
try rename tbl_name test
CalvinKirs Nov 22, 2023
b851413
try rename tbl_name test
CalvinKirs Nov 22, 2023
4ffa82f
try rename tbl_name test
CalvinKirs Nov 22, 2023
b05442c
try rename tbl_name test
CalvinKirs Nov 22, 2023
d5e9ac4
try rename tbl_name test
CalvinKirs Nov 22, 2023
bdff9ec
Magnify the waiting time. In extreme cases, it may be on the edge of …
CalvinKirs Nov 22, 2023
f9c2ea8
Merge remote-tracking branch 'origin/mv_3' into mv_3
CalvinKirs Nov 22, 2023
dac5aa0
1
zddr Nov 22, 2023
32f35ea
Merge remote-tracking branch 'origin/mv_3' into mv_3
zddr Nov 22, 2023
dd01959
mtmv doc
zddr Nov 23, 2023
5344f3e
rename MTMVCache to MTMVRelation
zddr Nov 23, 2023
719fc65
rename MTMVCache to MTMVRelation
zddr Nov 23, 2023
5715b11
add log
zddr Nov 23, 2023
0a4e2f3
add log
zddr Nov 23, 2023
8d015db
add log
zddr Nov 23, 2023
a7759cc
add log
zddr Nov 23, 2023
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
24 changes: 24 additions & 0 deletions be/src/vec/exec/scan/vmeta_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ Status VMetaScanner::_fetch_metadata(const TMetaScanRange& meta_scan_range) {
case TMetadataType::CATALOGS:
RETURN_IF_ERROR(_build_catalogs_metadata_request(meta_scan_range, &request));
break;
case TMetadataType::MATERIALIZED_VIEWS:
RETURN_IF_ERROR(_build_materialized_views_metadata_request(meta_scan_range, &request));
break;
case TMetadataType::QUERIES:
RETURN_IF_ERROR(_build_queries_metadata_request(meta_scan_range, &request));
break;
Expand Down Expand Up @@ -375,6 +378,27 @@ Status VMetaScanner::_build_catalogs_metadata_request(const TMetaScanRange& meta
return Status::OK();
}

Status VMetaScanner::_build_materialized_views_metadata_request(
zddr marked this conversation as resolved.
Show resolved Hide resolved
const TMetaScanRange& meta_scan_range, TFetchSchemaTableDataRequest* request) {
VLOG_CRITICAL << "VMetaScanner::_build_materialized_views_metadata_request";
if (!meta_scan_range.__isset.materialized_views_params) {
return Status::InternalError(
"Can not find TMaterializedViewsMetadataParams from meta_scan_range.");
}

// create request
request->__set_schema_table_name(TSchemaTableName::METADATA_TABLE);

// create TMetadataTableRequestParams
TMetadataTableRequestParams metadata_table_params;
metadata_table_params.__set_metadata_type(TMetadataType::MATERIALIZED_VIEWS);
metadata_table_params.__set_materialized_views_metadata_params(
meta_scan_range.materialized_views_params);

request->__set_metada_table_params(metadata_table_params);
return Status::OK();
}

Status VMetaScanner::_build_queries_metadata_request(const TMetaScanRange& meta_scan_range,
TFetchSchemaTableDataRequest* request) {
VLOG_CRITICAL << "VMetaScanner::_build_queries_metadata_request";
Expand Down
2 changes: 2 additions & 0 deletions be/src/vec/exec/scan/vmeta_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class VMetaScanner : public VScanner {
TFetchSchemaTableDataRequest* request);
Status _build_catalogs_metadata_request(const TMetaScanRange& meta_scan_range,
TFetchSchemaTableDataRequest* request);
Status _build_materialized_views_metadata_request(const TMetaScanRange& meta_scan_range,
TFetchSchemaTableDataRequest* request);
Status _build_queries_metadata_request(const TMetaScanRange& meta_scan_range,
TFetchSchemaTableDataRequest* request);
bool _meta_eos;
Expand Down
15 changes: 8 additions & 7 deletions fe/fe-common/src/main/java/org/apache/doris/common/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -1581,15 +1581,16 @@ public class Config extends ConfigBase {
@ConfField(description = {"任务堆积时用于存放定时任务的队列大小", "The number of timer jobs that can be queued."})
public static int job_dispatch_timer_job_queue_size = 1024;

/**
* The number of threads used to consume insert tasks.
* if you have a lot of insert jobs,and the average execution frequency is relatively high you need to increase
* this value or increase the number of {@code @job_insert_task_queue_size}
* The value should be greater than 0, if it is 0 or <=0, set it to 5
*/
@ConfField(description = {"用于执行 Insert 任务的线程数", "The number of threads used to consume insert tasks."})
@ConfField(description = {"用于执行 Insert 任务的线程数,值应该大于0,否则默认为5",
"The number of threads used to consume Insert tasks, "
+ "the value should be greater than 0, if it is <=0, default is 5."})
public static int job_insert_task_consumer_thread_num = 10;

@ConfField(description = {"用于执行 MTMV 任务的线程数,值应该大于0,否则默认为5",
"The number of threads used to consume mtmv tasks, "
+ "the value should be greater than 0, if it is <=0, default is 5."})
public static int job_mtmv_task_consumer_thread_num = 10;

/*---------------------- JOB CONFIG END------------------------*/
/**
* The number of async tasks that can be queued. @See TaskDisruptor
Expand Down
24 changes: 16 additions & 8 deletions fe/fe-core/src/main/cup/sql_parser.cup
Original file line number Diff line number Diff line change
Expand Up @@ -2595,16 +2595,28 @@ resume_job_stmt ::=
show_job_stmt ::=
KW_SHOW KW_JOBS
{:
RESULT = new ShowJobStmt(null,null,null);
RESULT = new ShowJobStmt(null,null);
:}
| KW_SHOW KW_JOB KW_FOR job_label:jobLabel
| KW_SHOW KW_MTMV KW_JOBS
{:
RESULT = new ShowJobStmt(null,org.apache.doris.job.common.JobType.MTMV);
:}
| KW_SHOW KW_MTMV KW_JOB KW_FOR job_label:jobLabel
{:
RESULT = new ShowJobStmt(null,jobLabel,null);
RESULT = new ShowJobStmt(jobLabel,org.apache.doris.job.common.JobType.MTMV);
:}
| KW_SHOW KW_JOB KW_FOR job_label:jobLabel
{:
RESULT = new ShowJobStmt(jobLabel,org.apache.doris.job.common.JobType.INSERT);
:}
| KW_SHOW KW_JOB KW_TASKS KW_FOR job_label:jobLabel
{:
RESULT = new ShowJobTaskStmt(null,jobLabel);
RESULT = new ShowJobTaskStmt(jobLabel,org.apache.doris.job.common.JobType.INSERT);
:}
| KW_SHOW KW_MTMV KW_JOB KW_TASKS KW_FOR job_label:jobLabel
{:
RESULT = new ShowJobTaskStmt(jobLabel,org.apache.doris.job.common.JobType.MTMV);
:}
;
pause_job_stmt ::=
KW_PAUSE KW_JOB KW_FOR job_label:jobLabel
Expand Down Expand Up @@ -2978,10 +2990,6 @@ drop_stmt ::=
{:
RESULT = new AlterTableStmt(tableName, Lists.newArrayList(new DropIndexClause(indexName, ifExists, tableName, false)));
:}
| KW_DROP KW_MATERIALIZED KW_VIEW opt_if_exists:ifExists table_name:mvName
{:
RESULT = new DropMaterializedViewStmt(ifExists, mvName);
:}
| KW_DROP KW_MATERIALIZED KW_VIEW opt_if_exists:ifExists ident:mvName KW_ON table_name:tableName
{:
RESULT = new DropMaterializedViewStmt(ifExists, mvName, tableName);
Expand Down
77 changes: 57 additions & 20 deletions fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.doris.analysis.DropMaterializedViewStmt;
import org.apache.doris.analysis.DropPartitionClause;
import org.apache.doris.analysis.DropPartitionFromIndexClause;
import org.apache.doris.analysis.DropTableStmt;
import org.apache.doris.analysis.ModifyColumnCommentClause;
import org.apache.doris.analysis.ModifyDistributionClause;
import org.apache.doris.analysis.ModifyEngineClause;
Expand All @@ -45,6 +44,7 @@
import org.apache.doris.catalog.DataProperty;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.MTMV;
import org.apache.doris.catalog.MysqlTable;
import org.apache.doris.catalog.OdbcTable;
import org.apache.doris.catalog.OlapTable;
Expand All @@ -62,6 +62,8 @@
import org.apache.doris.common.util.DynamicPartitionUtil;
import org.apache.doris.common.util.MetaLockUtils;
import org.apache.doris.common.util.PropertyAnalyzer;
import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo;
import org.apache.doris.persist.AlterMTMV;
import org.apache.doris.persist.AlterViewInfo;
import org.apache.doris.persist.BatchModifyPartitionsInfo;
import org.apache.doris.persist.ModifyCommentOperationLog;
Expand Down Expand Up @@ -120,26 +122,13 @@ public void processCreateMaterializedView(CreateMaterializedViewStmt stmt)
}

public void processDropMaterializedView(DropMaterializedViewStmt stmt) throws DdlException, MetaNotFoundException {
if (!stmt.isForMTMV() && stmt.getTableName() == null) {
throw new DdlException("Drop materialized view without table name is unsupported : " + stmt.toSql());
}

// drop materialized view
if (!stmt.isForMTMV()) {
TableName tableName = stmt.getTableName();

// check db
String dbName = tableName.getDb();
Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
TableName tableName = stmt.getTableName();
String dbName = tableName.getDb();
Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);

String name = tableName.getTbl();
OlapTable olapTable = (OlapTable) db.getTableOrMetaException(name, TableType.OLAP);
((MaterializedViewHandler) materializedViewHandler).processDropMaterializedView(stmt, db, olapTable);
} else {
DropTableStmt dropTableStmt = new DropTableStmt(stmt.isIfExists(), stmt.getMTMVName(), false);
dropTableStmt.setMaterializedView(true);
Env.getCurrentInternalCatalog().dropTable(dropTableStmt);
}
String name = tableName.getTbl();
OlapTable olapTable = (OlapTable) db.getTableOrMetaException(name, TableType.OLAP);
((MaterializedViewHandler) materializedViewHandler).processDropMaterializedView(stmt, db, olapTable);
}

private boolean processAlterOlapTable(AlterTableStmt stmt, OlapTable olapTable, List<AlterClause> alterClauses,
Expand All @@ -155,6 +144,10 @@ private boolean processAlterOlapTable(AlterTableStmt stmt, OlapTable olapTable,
AlterOperations currentAlterOps = new AlterOperations();
currentAlterOps.checkConflict(alterClauses);

if (olapTable instanceof MTMV) {
currentAlterOps.checkMTMVAllow(alterClauses);
}

// check cluster capacity and db quota, only need to check once.
if (currentAlterOps.needCheckCapacity()) {
Env.getCurrentSystemInfo().checkAvailableCapacity();
Expand Down Expand Up @@ -201,6 +194,8 @@ private boolean processAlterOlapTable(AlterTableStmt stmt, OlapTable olapTable,
} else if (currentAlterOps.hasSchemaChangeOp()) {
// if modify storage type to v2, do schema change to convert all related tablets to segment v2 format
schemaChangeHandler.process(stmt.toSql(), alterClauses, clusterName, db, olapTable);
// if base table schemaChanged, need change mtmv status
Env.getCurrentEnv().getMtmvService().alterTable(olapTable);
} else if (currentAlterOps.hasRollupOp()) {
materializedViewHandler.process(alterClauses, clusterName, db, olapTable);
} else if (currentAlterOps.hasPartitionOp()) {
Expand Down Expand Up @@ -256,6 +251,7 @@ private boolean processAlterOlapTable(AlterTableStmt stmt, OlapTable olapTable,
}
} else if (currentAlterOps.hasRenameOp()) {
processRename(db, olapTable, alterClauses);
Env.getCurrentEnv().getMtmvService().alterTable(olapTable);
} else if (currentAlterOps.hasReplaceTableOp()) {
processReplaceTable(db, olapTable, alterClauses);
} else if (currentAlterOps.contains(AlterOpType.MODIFY_TABLE_PROPERTY_SYNC)) {
Expand Down Expand Up @@ -877,4 +873,45 @@ public AlterHandler getMaterializedViewHandler() {
public AlterHandler getClusterHandler() {
return clusterHandler;
}

public void processAlterMTMV(AlterMTMV alterMTMV, boolean isReplay) {
TableNameInfo tbl = alterMTMV.getMvName();
MTMV mtmv = null;
try {
Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(tbl.getDb());
mtmv = (MTMV) db.getTableOrMetaException(tbl.getTbl(), TableType.MATERIALIZED_VIEW);

mtmv.writeLock();
switch (alterMTMV.getOpType()) {
case ALTER_REFRESH_INFO:
mtmv.alterRefreshInfo(alterMTMV.getRefreshInfo());
break;
case ALTER_STATUS:
mtmv.alterStatus(alterMTMV.getStatus());
break;
case ALTER_PROPERTY:
mtmv.alterMvProperties(alterMTMV.getMvProperties());
break;
case ADD_TASK:
mtmv.addTaskResult(alterMTMV.getTask(), alterMTMV.getCache());
Env.getCurrentEnv().getMtmvService()
.refreshComplete(mtmv, alterMTMV.getCache(), alterMTMV.getTask());
break;
default:
throw new RuntimeException("Unknown type value: " + alterMTMV.getOpType());
}
// 4. log it and replay it in the follower
if (!isReplay) {
Env.getCurrentEnv().getMtmvService().alterMTMV(mtmv, alterMTMV);
Env.getCurrentEnv().getEditLog().logAlterMTMV(alterMTMV);
}
} catch (UserException e) {
// if MTMV has been dropped, ignore this exception
LOG.warn(e);
} finally {
if (mtmv != null) {
mtmv.writeUnlock();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ public boolean needCheckCapacity() {
return this == ADD_ROLLUP || this == SCHEMA_CHANGE || this == ADD_PARTITION || this == ENABLE_FEATURE;
}

public boolean mtmvAllowOp() {
return this == MODIFY_TABLE_PROPERTY || this == MODIFY_DISTRIBUTION || this == MODIFY_TABLE_COMMENT
|| this == ADD_PARTITION || this == DROP_PARTITION || this == REPLACE_PARTITION
|| this == MODIFY_PARTITION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public void checkConflict(List<AlterClause> alterClauses) throws DdlException {
}
}

public void checkMTMVAllow(List<AlterClause> alterClauses) throws DdlException {
for (AlterClause alterClause : alterClauses) {
if (!alterClause.getOpType().mtmvAllowOp()) {
throw new DdlException("Alter operation " + alterClause.getOpType() + " Not allowed to MTMV");
}
}
}

// some operations take up disk space. so we need to check the disk capacity before processing.
// return true if we see these kind of operations.
public boolean needCheckCapacity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public class CreateJobStmt extends DdlStmt {
private final String comment;
private JobExecuteType executeType;

private String timezone = TimeUtils.DEFAULT_TIME_ZONE;

private static final ImmutableSet<Class<? extends DdlStmt>> supportStmtSuperClass
= new ImmutableSet.Builder<Class<? extends DdlStmt>>().add(InsertStmt.class)
.add(UpdateStmt.class).build();
Expand Down Expand Up @@ -114,7 +112,7 @@ public void analyze(Analyzer analyzer) throws UserException {
Env.getCurrentInternalCatalog().getDbOrAnalysisException(dbName);
analyzerSqlStmt();
// check its insert stmt,currently only support insert stmt
//todo used InsertIntoCommand if job is InsertJob
//todo when support other stmt,need to check stmt type and generate jobInstance
InsertJob job = new InsertJob();
JobExecutionConfiguration jobExecutionConfiguration = new JobExecutionConfiguration();
jobExecutionConfiguration.setExecuteType(executeType);
Expand Down Expand Up @@ -144,10 +142,12 @@ public void analyze(Analyzer analyzer) throws UserException {
job.setJobName(labelName.getLabelName());
job.setCreateUser(ConnectContext.get().getCurrentUserIdentity());
job.setJobStatus(JobStatus.RUNNING);
job.checkJobParams();
job.setJobId(Env.getCurrentEnv().getNextId());
String originStmt = getOrigStmt().originStmt;
String executeSql = parseExecuteSql(originStmt);
job.setExecuteSql(executeSql);

//job.checkJobParams();
jobInstance = job;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// 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.doris.analysis;

import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.Index;
import org.apache.doris.mtmv.EnvInfo;
import org.apache.doris.mtmv.MTMVRefreshInfo;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class CreateMTMVStmt extends CreateTableStmt {
private final MTMVRefreshInfo refreshInfo;
private final String querySql;
private final EnvInfo envInfo;
private Map<String, String> mvProperties;

public CreateMTMVStmt(boolean ifNotExists, TableName mvName, List<Column> columns,
MTMVRefreshInfo refreshInfo, KeysDesc keyDesc, DistributionDesc distributionDesc,
Map<String, String> properties, Map<String, String> mvProperties, String querySql, String comment,
EnvInfo envInfo) {
super(ifNotExists, false, mvName, columns, new ArrayList<Index>(), DEFAULT_ENGINE_NAME, keyDesc, null,
distributionDesc, properties, null, comment, null, null);
this.refreshInfo = refreshInfo;
this.querySql = querySql;
this.envInfo = envInfo;
this.mvProperties = mvProperties;
}

public MTMVRefreshInfo getRefreshInfo() {
return refreshInfo;
}

public String getQuerySql() {
return querySql;
}

public EnvInfo getEnvInfo() {
return envInfo;
}

public Map<String, String> getMvProperties() {
return mvProperties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class CreateTableStmt extends DdlStmt {

protected static final String DEFAULT_ENGINE_NAME = "olap";

private boolean ifNotExists;
protected boolean ifNotExists;
private boolean isExternal;
protected TableName tableName;
protected List<ColumnDef> columnDefs;
Expand Down Expand Up @@ -244,7 +244,7 @@ public CreateTableStmt(boolean ifNotExists,
this.extProperties = extProperties;
this.columnDefs = Lists.newArrayList();
this.comment = Strings.nullToEmpty(comment);
this.rollupAlterClauseList = rollupAlterClauseList;
this.rollupAlterClauseList = (rollupAlterClauseList == null) ? Lists.newArrayList() : rollupAlterClauseList;
}

public void addColumnDef(ColumnDef columnDef) {
Expand Down
Loading
Loading