diff --git a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatDynamicPartitioned.java b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatDynamicPartitioned.java index 0d87c6c..b504894 100644 --- a/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatDynamicPartitioned.java +++ b/hcatalog/core/src/test/java/org/apache/hive/hcatalog/mapreduce/TestHCatDynamicPartitioned.java @@ -54,10 +54,12 @@ private static final Logger LOG = LoggerFactory.getLogger(TestHCatDynamicPartitioned.class); protected static final int NUM_RECORDS = 20; protected static final int NUM_PARTITIONS = 5; + protected static String DEFAULT_PARTITION_NAME; public TestHCatDynamicPartitioned(String formatName, String serdeClass, String inputFormatClass, String outputFormatClass) throws Exception { super(formatName, serdeClass, inputFormatClass, outputFormatClass); + DEFAULT_PARTITION_NAME = HiveConf.getVar(new HiveConf(), HiveConf.ConfVars.DEFAULTPARTITIONNAME); tableName = "testHCatDynamicPartitionedTable_" + formatName; generateWriteRecords(NUM_RECORDS, NUM_PARTITIONS, 0); generateDataColumns(); @@ -73,7 +75,7 @@ protected static void generateDataColumns() throws HCatException { protected static void generateWriteRecords(int max, int mod, int offset) { writeRecords = new ArrayList(); - for (int i = 0; i < max; i++) { + for (int i = 0; i < max-1; i++) { List objList = new ArrayList(); objList.add(i); @@ -81,6 +83,13 @@ protected static void generateWriteRecords(int max, int mod, int offset) { objList.add(String.valueOf((i % mod) + offset)); writeRecords.add(new DefaultHCatRecord(objList)); } + + // add one null key obj in as well + List objList = new ArrayList(); + objList.add(max); + objList.add("strvalue" + max); + objList.add(null); + writeRecords.add(new DefaultHCatRecord(objList)); } @Override @@ -124,9 +133,10 @@ protected void runHCatDynamicPartitionedTable(boolean asSingleMapTask, runMRRead(NUM_RECORDS); //Read with partition filter - runMRRead(4, "p1 = \"0\""); - runMRRead(8, "p1 = \"1\" or p1 = \"3\""); - runMRRead(4, "p1 = \"4\""); + runMRRead(NUM_RECORDS/5, "p1 = \"0\""); + runMRRead((NUM_RECORDS*2)/5, "p1 = \"1\" or p1 = \"3\""); + runMRRead((NUM_RECORDS/5)-1, "p1 = \"4\""); // -1 because max creates a DEFAULT_PARTITION as the last one. + runMRRead(1, "p1 = \""+DEFAULT_PARTITION_NAME+"\""); // read from hive to test @@ -175,7 +185,7 @@ protected void runHCatDynamicPartitionedTable(boolean asSingleMapTask, } res = new ArrayList(); driver.getResults(res); - assertEquals(NUM_PARTITIONS, res.size()); + assertEquals(NUM_PARTITIONS+1, res.size()); // +1 because of null key creating a separate DEFAULT ptn query = "select * from " + tableName; retCode = driver.run(query).getResponseCode();