From 7669f81ce38ef7b4e8106911772db195e7a56a6c Mon Sep 17 00:00:00 2001 From: daidai Date: Tue, 26 Nov 2024 13:12:10 +0800 Subject: [PATCH] ban create insert drop translational tb. --- .../datasource/hive/HiveMetadataOps.java | 24 +++++++++++++++++++ .../insert/InsertIntoTableCommand.java | 5 ++++ 2 files changed, 29 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetadataOps.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetadataOps.java index a660cb148ac0695..4a11cf9b01fce90 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetadataOps.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/hive/HiveMetadataOps.java @@ -46,6 +46,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.ql.io.AcidUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -179,6 +180,25 @@ public boolean createTable(CreateTableStmt stmt) throws UserException { props.put("owner", ConnectContext.get().getUserIdentity().getUser()); } } + + if (props.containsKey("transactional") && props.get("transactional").equals("true")) { + throw new UserException("Not support create hive transactional table."); + /* + CREATE TABLE trans6( + `col1` int, + `col2` int + ) ENGINE=hive + PROPERTIES ( + 'file_format'='orc', + 'compression'='zlib', + 'bucketing_version'='2', + 'transactional'='true', + 'transactional_properties'='default' + ); + In hive, this table only can insert not update(not report error,but not actually updated). + */ + } + String fileFormat = props.getOrDefault(FILE_FORMAT_KEY, Config.hive_default_file_format); Map ddlProps = new HashMap<>(); for (Map.Entry entry : props.entrySet()) { @@ -273,6 +293,10 @@ public void dropTable(DropTableStmt stmt) throws DdlException { ErrorReport.reportDdlException(ErrorCode.ERR_UNKNOWN_TABLE, tblName, dbName); } } + if (AcidUtils.isTransactionalTable(client.getTable(dbName, tblName))) { + throw new DdlException("Not support drop hive transactional table."); + } + try { client.dropTable(dbName, tblName); db.setUnInitialized(true); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java index 0999c4baa79e3b1..5810a07bb197c19 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/InsertIntoTableCommand.java @@ -24,6 +24,7 @@ import org.apache.doris.catalog.TableIf; import org.apache.doris.common.ErrorCode; import org.apache.doris.common.ErrorReport; +import org.apache.doris.common.UserException; import org.apache.doris.common.profile.ProfileManager.ProfileType; import org.apache.doris.datasource.hive.HMSExternalTable; import org.apache.doris.datasource.iceberg.IcebergExternalTable; @@ -269,6 +270,10 @@ private ExecutorFactory selectInsertExecutorFactory( } else if (physicalSink instanceof PhysicalHiveTableSink) { boolean emptyInsert = childIsEmptyRelation(physicalSink); HMSExternalTable hiveExternalTable = (HMSExternalTable) targetTableIf; + if (hiveExternalTable.isHiveTransactionalTable()) { + throw new UserException("Not supported insert into hive table"); + } + return ExecutorFactory.from( planner, dataSink,