[ https://issues.apache.org/jira/browse/HIVE-27268?focusedWorklogId=860996&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-860996 ]
ASF GitHub Bot logged work on HIVE-27268: ----------------------------------------- Author: ASF GitHub Bot Created on: 08/May/23 11:22 Start Date: 08/May/23 11:22 Worklog Time Spent: 10m Work Description: henrib commented on code in PR #4241: URL: https://github.com/apache/hive/pull/4241#discussion_r1187329741 ########## ql/src/test/org/apache/hadoop/hive/ql/TestTxnNoBuckets.java: ########## @@ -909,5 +910,30 @@ public void testEmptyCompactionResult() throws Exception { Assert.assertEquals(stringifyValues(data), rs); } + + /** + * HIVE-27268 + */ + @Test + public void testGetPartitionsNoSession() throws Exception { + hiveConf.setIntVar(HiveConf.ConfVars.HIVEOPTSORTDYNAMICPARTITIONTHRESHOLD, -1); + runStatementOnDriver("drop table if exists T"); + runStatementOnDriver("create table T(a int, b int) partitioned by (p int, q int) " + + "stored as orc TBLPROPERTIES ('transactional'='true')"); + + int[][] targetVals = {{4, 1, 1}, {4, 2, 2}, {4, 3, 1}, {4, 4, 2}}; + //we only recompute stats after major compact if they existed before + runStatementOnDriver("insert into T partition(p=1,q) " + makeValuesClause(targetVals)); + runStatementOnDriver("analyze table T partition(p=1) compute statistics for columns"); + + Hive hive = Hive.get(); + org.apache.hadoop.hive.ql.metadata.Table hiveTable = hive.getTable("T"); + // this will ensure the getValidWriteIdList has no session to work with (thru getPartitions) + SessionState.detachSession(); + List<org.apache.hadoop.hive.ql.metadata.Partition> partitions = hive.getPartitions(hiveTable); + Assert.assertNotNull(partitions); + // prevent tear down failure + d = null; Review Comment: Implies protecting against the 'null' session in context.close(), done. Issue Time Tracking ------------------- Worklog Id: (was: 860996) Time Spent: 1.5h (was: 1h 20m) > Hive.getPartitionsByNames should not enforce SessionState to be available > ------------------------------------------------------------------------- > > Key: HIVE-27268 > URL: https://issues.apache.org/jira/browse/HIVE-27268 > Project: Hive > Issue Type: Bug > Components: Hive > Affects Versions: 3.1.3 > Reporter: Henri Biestro > Priority: Minor > Labels: pull-request-available > Fix For: 4.0.0 > > Time Spent: 1.5h > Remaining Estimate: 0h > > HIVE-24743, HIVE-24392 is enforcing to check for valid write Id list for > "Hive.getPartitionsByName". > This breaks basic API integration. For a user who needs to get basic > partition detail, he is forced to have SessionState. > Request in this ticket is to ensure that if SessionState.get() is null, it > should return empty validWriteIdList. -- This message was sent by Atlassian Jira (v8.20.10#820010)