@Test(expected = MetaException.class) public void testGetPartitionByValuesNullDbName() throws Exception { createTable3PartCols1Part(client); client.getPartition(null, TABLE_NAME, Lists.newArrayList("1997", "05", "16")); }
@Test(expected = NoSuchObjectException.class) public void testGetPartitionByValuesWrongPart() throws Exception { createTable3PartCols1Part(client); client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList("1997", "05", "66")); }
@Test(expected = NoSuchObjectException.class) public void testGetPartitionByValuesNoDbName() throws Exception { createTable3PartCols1Part(client); client.getPartition("", TABLE_NAME, Lists.newArrayList("1997", "05", "16")); }
@Test(expected = MetaException.class) public void testGetPartitionByValuesNullTblName() throws Exception { createTable3PartCols1Part(client); client.getPartition(DB_NAME, null, Lists.newArrayList("1997", "05", "16")); }
@Test(expected = NoSuchObjectException.class) public void testGetPartitionByValuesNoTblName() throws Exception { createTable3PartCols1Part(client); client.getPartition(DB_NAME, "", Lists.newArrayList("1997", "05", "16")); }
@Test(expected = NoSuchObjectException.class) public void testGetPartitionByValuesNoDb() throws Exception { client.dropDatabase(DB_NAME); client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList("1997", "05", "16")); }
@Test(expected = MetaException.class) public void testGetPartitionEmptyPartName() throws Exception { createTable3PartCols1Part(client); client.getPartition(DB_NAME, TABLE_NAME, ""); }
@Test(expected = NoSuchObjectException.class) public void testGetPartitionNoTblName() throws Exception { createTable3PartCols1Part(client); client.getPartition(DB_NAME, "", "yyyy=1997/mm=05/dd=16"); }
@Test(expected = NoSuchObjectException.class) public void testGetPartitionCaseSensitive() throws Exception { createTable3PartCols1Part(client); client.getPartition(DB_NAME, TABLE_NAME, "YyYy=1997/mM=05/dD=16"); }
@Test(expected = NoSuchObjectException.class) public void testGetPartitionNoDb() throws Exception { client.dropDatabase(DB_NAME); client.getPartition(DB_NAME, TABLE_NAME, "yyyy=1997/mm=05/dd=16"); }
@Test(expected = MetaException.class) public void testGetPartitionNullDbName() throws Exception { createTable3PartCols1Part(client); client.getPartition(null, TABLE_NAME, "yyyy=1997/mm=05/dd=16"); }
private void verifyStatsUpToDate(String tbl, String part, ArrayList<String> cols, IMetaStoreClient msClient, boolean isUpToDate) throws Exception { Partition partition = msClient.getPartition(ss.getCurrentDatabase(), tbl, part); verifyStatsUpToDate(partition.getParameters(), cols, isUpToDate); }
private void setPartitionSkipProperty( IMetaStoreClient msClient, String tblName, String partName, String val) throws Exception { Partition part = msClient.getPartition(ss.getCurrentDatabase(), tblName, partName); part.getParameters().put(StatsUpdaterThread.SKIP_STATS_AUTOUPDATE_PROPERTY, val); msClient.alter_partition(part.getCatName(), part.getDbName(), tblName, part); }
/** * Testing getPartition(String,String,String) -> * get_partition_by_name(String,String,String). */ @Test public void testGetPartition() throws Exception { createTable3PartCols1Part(client); Partition partition = client.getPartition(DB_NAME, TABLE_NAME, "yyyy=1997/mm=05/dd=16"); assertNotNull(partition); assertEquals(Lists.newArrayList("1997", "05", "16"), partition.getValues()); }
@Test public void testAddPartitionsForViewNullPartSd() throws Exception { String tableName = "test_add_partition_view"; createView(tableName); Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE); partition.setSd(null); List<Partition> partitions = Lists.newArrayList(partition); client.add_partitions(partitions); Partition part = client.getPartition(DB_NAME, tableName, "year=2017"); Assert.assertNull(part.getSd()); }
@Test public void testAddPartitionsForViewNullPartLocation() throws Exception { String tableName = "test_add_partition_view"; createView(tableName); Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE); partition.getSd().setLocation(null); List<Partition> partitions = Lists.newArrayList(partition); client.add_partitions(partitions); Partition part = client.getPartition(DB_NAME, tableName, "year=2017"); Assert.assertNull(part.getSd().getLocation()); }
@Test public void testAddPartitionSpecSetRootPath() throws Exception { Table table = createTable(); String rootPath = table.getSd().getLocation() + "/addPartSpecRootPath/"; String rootPath1 = table.getSd().getLocation() + "/someotherpath/"; Partition partition = buildPartition(DB_NAME, TABLE_NAME, "2007", rootPath + "part2007/"); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, TABLE_NAME, rootPath1, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); Partition resultPart = client.getPartition(DB_NAME, TABLE_NAME, Lists.newArrayList("2007")); Assert.assertEquals(rootPath + "part2007", resultPart.getSd().getLocation()); }
@Test public void testAddPartitionSpecForViewNullPartLocation() throws Exception { String tableName = "test_add_partition_view"; createView(tableName); Partition partition = buildPartition(DB_NAME, tableName, DEFAULT_YEAR_VALUE); partition.getSd().setLocation(null); PartitionSpecProxy partitionSpecProxy = buildPartitionSpec(DB_NAME, tableName, null, Lists.newArrayList(partition)); client.add_partitions_pspec(partitionSpecProxy); Partition part = client.getPartition(DB_NAME, tableName, "year=2017"); Assert.assertNull(part.getSd().getLocation()); }
@Test public void testAddPartitionNullLocationInTableToo() throws Exception { createTable(DB_NAME, TABLE_NAME, null); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, null); client.add_partition(partition); Partition part = client.getPartition(DB_NAME, TABLE_NAME, "year=2017"); Assert.assertEquals( metaStore.getWarehouseRoot() + "/test_partition_db.db/test_partition_table/year=2017", part.getSd().getLocation()); Assert.assertTrue(metaStore.isPathExists(new Path(part.getSd().getLocation()))); }
@Test public void testAddPartitionEmptyLocation() throws Exception { createTable(DB_NAME, TABLE_NAME, metaStore.getWarehouseRoot() + "/addparttest3"); Partition partition = buildPartition(DB_NAME, TABLE_NAME, DEFAULT_YEAR_VALUE, ""); client.add_partition(partition); Partition part = client.getPartition(DB_NAME, TABLE_NAME, "year=2017"); Assert.assertEquals(metaStore.getWarehouseRoot() + "/addparttest3/year=2017", part.getSd().getLocation()); Assert.assertTrue(metaStore.isPathExists(new Path(part.getSd().getLocation()))); }