Skip to content

Commit

Permalink
HIVE-14004. Fix ArrayIndexOutOfBounds in schema evolution when using …
Browse files Browse the repository at this point in the history
…ACID.
  • Loading branch information
omalley committed Jul 14, 2016
1 parent 97da313 commit 502c652
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public RecordReader rowsOptions(Options options) throws IOException {
boolean[] include = options.getInclude();
// if included columns is null, then include all columns
if (include == null) {
options = options.clone();
include = new boolean[types.size()];
Arrays.fill(include, true);
options.include(include);
Expand Down
28 changes: 26 additions & 2 deletions ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ public void testInitiatorWithMultipleFailedCompactions() throws Exception {
init.run();
int numAttemptedCompactions = 1;
checkCompactionState(new CompactionsByState(numAttemptedCompactions,numFailedCompactions,0,0,0,0,numFailedCompactions + numAttemptedCompactions), countCompacts(txnHandler));

hiveConf.setTimeVar(HiveConf.ConfVars.COMPACTOR_HISTORY_REAPER_INTERVAL, 10, TimeUnit.MILLISECONDS);
AcidCompactionHistoryService compactionHistoryService = new AcidCompactionHistoryService();
runHouseKeeperService(compactionHistoryService, hiveConf);//should not remove anything from history
Expand All @@ -868,7 +868,7 @@ public void testInitiatorWithMultipleFailedCompactions() throws Exception {
hiveConf.getIntVar(HiveConf.ConfVars.COMPACTOR_HISTORY_RETENTION_ATTEMPTED),
hiveConf.getIntVar(HiveConf.ConfVars.COMPACTOR_HISTORY_RETENTION_FAILED),0,0,0,0,
hiveConf.getIntVar(HiveConf.ConfVars.COMPACTOR_HISTORY_RETENTION_FAILED) + hiveConf.getIntVar(HiveConf.ConfVars.COMPACTOR_HISTORY_RETENTION_ATTEMPTED)), countCompacts(txnHandler));

hiveConf.setBoolVar(HiveConf.ConfVars.HIVETESTMODEFAILCOMPACTION, false);
txnHandler.compact(new CompactionRequest("default", tblName, CompactionType.MINOR));
//at this point "show compactions" should have (COMPACTOR_HISTORY_RETENTION_FAILED) failed + 1 initiated (explicitly by user)
Expand Down Expand Up @@ -1139,6 +1139,30 @@ public void testOpenTxnsCounter() throws Exception {
Assert.assertNull(exception);
}

@Test
public void testCompactWithDelete() throws Exception {
int[][] tableData = {{1,2},{3,4}};
runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(tableData));
runStatementOnDriver("alter table "+ Table.ACIDTBL + " compact 'MAJOR'");
Worker t = new Worker();
t.setThreadId((int) t.getId());
t.setHiveConf(hiveConf);
AtomicBoolean stop = new AtomicBoolean();
AtomicBoolean looped = new AtomicBoolean();
stop.set(true);
t.init(stop, looped);
t.run();
runStatementOnDriver("delete from " + Table.ACIDTBL + " where b = 4");
runStatementOnDriver("update " + Table.ACIDTBL + " set b = -2 where b = 2");
runStatementOnDriver("alter table "+ Table.ACIDTBL + " compact 'MINOR'");
t.run();
TxnStore txnHandler = TxnUtils.getTxnStore(hiveConf);
ShowCompactResponse resp = txnHandler.showCompact(new ShowCompactRequest());
Assert.assertEquals("Unexpected number of compactions in history", 2, resp.getCompactsSize());
Assert.assertEquals("Unexpected 0 compaction state", TxnStore.CLEANING_RESPONSE, resp.getCompacts().get(0).getState());
Assert.assertEquals("Unexpected 1 compaction state", TxnStore.CLEANING_RESPONSE, resp.getCompacts().get(1).getState());
}

/**
* takes raw data and turns it into a string as if from Driver.getResults()
* sorts rows in dictionary order
Expand Down

0 comments on commit 502c652

Please sign in to comment.