Skip to content

Commit

Permalink
ban create insert drop translational tb.
Browse files Browse the repository at this point in the history
  • Loading branch information
hubgeter committed Nov 26, 2024
1 parent b65c8e1 commit 7669f81
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<String, String> ddlProps = new HashMap<>();
for (Map.Entry<String, String> entry : props.entrySet()) {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7669f81

Please sign in to comment.