Skip to content

Commit

Permalink
[merge](hive) insert overwrite command support iceberg operator
Browse files Browse the repository at this point in the history
  • Loading branch information
lik40 committed Jul 3, 2024
1 parent e86531e commit 35427ca
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.InternalDatabaseUtil;
import org.apache.doris.datasource.hive.HMSExternalTable;
import org.apache.doris.datasource.iceberg.IcebergExternalTable;
import org.apache.doris.insertoverwrite.InsertOverwriteUtil;
import org.apache.doris.mtmv.MTMVUtil;
import org.apache.doris.mysql.privilege.PrivPredicate;
Expand Down Expand Up @@ -111,10 +112,14 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
}

TableIf targetTableIf = InsertUtils.getTargetTable(logicalQuery, ctx);
if (!(targetTableIf instanceof OlapTable || targetTableIf instanceof HMSExternalTable)) {
throw new AnalysisException("insert into overwrite only support OLAP and HMS table."
+ " But current table type is " + targetTableIf.getType());
//check allow insert overwrite
if (!allowInsertOverwrite(targetTableIf)) {
String errMsg = "insert into overwrite only support OLAP and HMS/ICEBERG table."
+ " But current table type is " + targetTableIf.getType();
LOG.error(errMsg);
throw new AnalysisException(errMsg);
}
//check allow modify MTMVData
if (targetTableIf instanceof MTMV && !MTMVUtil.allowModifyMTMVData(ctx)) {
throw new AnalysisException("Not allowed to perform current operation on async materialized view");
}
Expand Down Expand Up @@ -190,8 +195,16 @@ public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
}
}

private boolean allowInsertOverwrite(TableIf targetTable) {
if (targetTable instanceof OlapTable) {
return true;
} else {
return targetTable instanceof HMSExternalTable || targetTable instanceof IcebergExternalTable;
}
}

private void runInsertCommand(LogicalPlan logicalQuery, InsertCommandContext insertCtx,
ConnectContext ctx, StmtExecutor executor) throws Exception {
ConnectContext ctx, StmtExecutor executor) throws Exception {
InsertIntoTableCommand insertCommand = new InsertIntoTableCommand(logicalQuery, labelName,
Optional.of(insertCtx), Optional.empty());
insertCommand.run(ctx, executor);
Expand All @@ -205,8 +218,8 @@ private void runInsertCommand(LogicalPlan logicalQuery, InsertCommandContext ins
/**
* insert into select. for sepecified temp partitions
*
* @param ctx ctx
* @param executor executor
* @param ctx ctx
* @param executor executor
* @param tempPartitionNames tempPartitionNames
*/
private void insertInto(ConnectContext ctx, StmtExecutor executor, List<String> tempPartitionNames)
Expand Down Expand Up @@ -250,7 +263,7 @@ private void insertInto(ConnectContext ctx, StmtExecutor executor, List<String>
/**
* insert into auto detect partition.
*
* @param ctx ctx
* @param ctx ctx
* @param executor executor
*/
private void insertInto(ConnectContext ctx, StmtExecutor executor, long groupId) throws Exception {
Expand Down

0 comments on commit 35427ca

Please sign in to comment.