[ https://issues.apache.org/jira/browse/HIVE-26414?focusedWorklogId=797136&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-797136 ]
ASF GitHub Bot logged work on HIVE-26414: ----------------------------------------- Author: ASF GitHub Bot Created on: 02/Aug/22 07:19 Start Date: 02/Aug/22 07:19 Worklog Time Spent: 10m Work Description: SourabhBadhya commented on code in PR #3457: URL: https://github.com/apache/hive/pull/3457#discussion_r935200343 ########## ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java: ########## @@ -3080,6 +3084,83 @@ public void testAcidOrcWritePreservesFieldNames() throws Exception { hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_VECTORIZATION_ENABLED, true); } + @Test + public void testFailureScenariosCleanupCTAS() throws Exception { + boolean[] booleans = {true, false}; + for (boolean var1 : booleans) { + for (boolean var2 : booleans) { + for (boolean var3 : booleans) { + for (boolean var4 : booleans) { + failureScenarioCleanupCTAS(var1, var2, var3, var4); + } + } + } + } + } + + public void failureScenarioCleanupCTAS(boolean isPartitioned, + boolean isDirectInsertEnabled, + boolean isLocklessReadsEnabled, + boolean isLocationUsed) throws Exception { + String tableName = "atable"; + + //Set configurations + hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_ACID_DIRECT_INSERT_ENABLED, isDirectInsertEnabled); + hiveConf.setBoolVar(HiveConf.ConfVars.HIVE_ACID_LOCKLESS_READS_ENABLED, isLocklessReadsEnabled); + hiveConf.setBoolVar(HiveConf.ConfVars.TXN_CTAS_X_LOCK, true); + hiveConf.setIntVar(HiveConf.ConfVars.HIVE_COMPACTOR_ABORTEDTXN_THRESHOLD, 0); + + // Add a '1' at the end of table name for custom location. + String querylocation = (isLocationUsed) ? " location '" + getWarehouseDir() + "/" + tableName + "1'" : ""; + String queryPartitions = (isPartitioned) ? " partitioned by (a)" : ""; + + d.run("insert into " + Table.ACIDTBL + "(a,b) values (3,4)"); + d.run("drop table if exists " + tableName); + d.compileAndRespond("create table " + tableName + queryPartitions + " stored as orc" + querylocation + + " tblproperties ('transactional'='true') as select * from " + Table.ACIDTBL); + long txnId = d.getQueryState().getTxnManager().getCurrentTxnId(); + DriverContext driverContext = d.getDriverContext(); + traverseTasksRecursively(driverContext.getPlan().getRootTasks()); + int assertError = 0; + try { + d.run(); + } catch (Exception e) { + assertError = 1; + } + + runInitiator(hiveConf); Review Comment: Removed. Done. Issue Time Tracking ------------------- Worklog Id: (was: 797136) Time Spent: 12h 20m (was: 12h 10m) > Aborted/Cancelled CTAS operations must initiate cleanup of uncommitted data > --------------------------------------------------------------------------- > > Key: HIVE-26414 > URL: https://issues.apache.org/jira/browse/HIVE-26414 > Project: Hive > Issue Type: Improvement > Reporter: Sourabh Badhya > Assignee: Sourabh Badhya > Priority: Major > Labels: pull-request-available > Time Spent: 12h 20m > Remaining Estimate: 0h > > When a CTAS query fails before creation of table and after writing the data, > the data is present in the directory and not cleaned up currently by the > cleaner or any other mechanism currently. This is because the cleaner > requires a table corresponding to what its cleaning. In order surpass such a > situation, we can directly pass the relevant information to the cleaner so > that such uncommitted data is deleted. -- This message was sent by Atlassian Jira (v8.20.10#820010)