deniskuzZ commented on code in PR #3457:
URL: https://github.com/apache/hive/pull/3457#discussion_r926391951
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
Review Comment:
could we pass a `Context ctx` here instead of initializing the destination
table when acquiring locks?
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.TXN_CTAS_X_LOCK)) {
Review Comment:
shouldn't we check that this was a CTAS operation? do we only need to
cleanup if an exclusive lock is enabled?
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.TXN_CTAS_X_LOCK)) {
+ if (destinationTable != null) {
+ try {
+ CompactionRequest rqst = new CompactionRequest(
+ destinationTable.getDbName(),
destinationTable.getTableName(), CompactionType.MAJOR);
+
rqst.setRunas(TxnUtils.findUserToRunAs(destinationTable.getSd().getLocation(),
+ destinationTable.getTTable(), conf));
+
+ rqst.putToProperties("location",
destinationTable.getSd().getLocation());
Review Comment:
use hive_metastoreConstants.META_TABLE_LOCATION?
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -29,19 +29,10 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
import org.apache.hadoop.hive.metastore.LockComponentBuilder;
import org.apache.hadoop.hive.metastore.LockRequestBuilder;
-import org.apache.hadoop.hive.metastore.api.LockComponent;
-import org.apache.hadoop.hive.metastore.api.LockResponse;
-import org.apache.hadoop.hive.metastore.api.LockState;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.NoSuchLockException;
-import org.apache.hadoop.hive.metastore.api.NoSuchTxnException;
-import org.apache.hadoop.hive.metastore.api.TxnAbortedException;
-import org.apache.hadoop.hive.metastore.api.TxnToWriteId;
-import org.apache.hadoop.hive.metastore.api.CommitTxnRequest;
-import org.apache.hadoop.hive.metastore.api.DataOperationType;
-import org.apache.hadoop.hive.metastore.api.GetOpenTxnsResponse;
-import org.apache.hadoop.hive.metastore.api.TxnType;
+import org.apache.hadoop.hive.metastore.api.*;
Review Comment:
please avoid wildcard imports
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.TXN_CTAS_X_LOCK)) {
+ if (destinationTable != null) {
+ try {
+ CompactionRequest rqst = new CompactionRequest(
+ destinationTable.getDbName(),
destinationTable.getTableName(), CompactionType.MAJOR);
+
rqst.setRunas(TxnUtils.findUserToRunAs(destinationTable.getSd().getLocation(),
+ destinationTable.getTTable(), conf));
+
+ rqst.putToProperties("location",
destinationTable.getSd().getLocation());
+ rqst.putToProperties("ifPurge", Boolean.toString(true));
+ TxnStore txnHandler = TxnUtils.getTxnStore(conf);
+ txnHandler.submitForCleanup(rqst,
destinationTable.getTTable().getWriteId(), getCurrentTxnId());
+ } catch (InterruptedException | IOException | MetaException e) {
+ throw new RuntimeException("Not able to submit cleanup operation of
directory written by CTAS");
Review Comment:
should we catch just InterruptedException | IOException and re-throw
MetaException here?
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java:
##########
@@ -7852,6 +7852,10 @@ protected Operator genFileSinkPlan(String dest, QB qb,
Operator input)
throw new SemanticException("Error while getting the full qualified
path for the given directory: " + ex.getMessage());
}
}
+
+ if (!isNonNativeTable &&
AcidUtils.isTransactionalTable(destinationTable) && qb.isCTAS()) {
Review Comment:
is `!isNonNativeTable` required to exclude Iceberg tables?
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.TXN_CTAS_X_LOCK)) {
+ if (destinationTable != null) {
+ try {
+ CompactionRequest rqst = new CompactionRequest(
+ destinationTable.getDbName(),
destinationTable.getTableName(), CompactionType.MAJOR);
+
rqst.setRunas(TxnUtils.findUserToRunAs(destinationTable.getSd().getLocation(),
+ destinationTable.getTTable(), conf));
+
+ rqst.putToProperties("location",
destinationTable.getSd().getLocation());
+ rqst.putToProperties("ifPurge", Boolean.toString(true));
Review Comment:
would be good if we move "ifPurge" under constants as well
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]