@Override public TableWriterPair run() throws Exception { return new TableWriterPair(msClient.getTable(endPoint.database, endPoint.table), getPathForEndPoint(msClient, endPoint)); } });
@Before public void before() throws Exception { createPartitionedTable(catName, dbName, tableName); table = db.getTable(catName, dbName, tableName); repairOutput = new ArrayList<String>(); }
@Before public void before() throws Exception { createPartitionedTable(catName, dbName, tableName); table = db.getTable(catName, dbName, tableName); repairOutput = new ArrayList<String>(); }
@Test(expected = NoSuchObjectException.class) public void testGetTableNoSuchDatabase() throws Exception { Table table = testTables[2]; client.getTable("no_such_database", table.getTableName()); }
@Test public void testGetTableCaseInsensitive() throws Exception { Table table = testTables[0]; // Test in upper case Table resultUpper = client.getTable(table.getCatName().toUpperCase(), table.getDbName().toUpperCase(), table.getTableName().toUpperCase()); Assert.assertEquals("Comparing tables", table, resultUpper); // Test in mixed case Table resultMix = client.getTable("hIvE", "DeFaUlt", "tEsT_TabLE"); Assert.assertEquals("Comparing tables", table, resultMix); }
@Test public void testMetaStoreFailsOnConnect() throws Exception { when(mockMetaStoreClient.getTable(anyString(), anyString())).thenThrow(new TException()); try { client.connect(); fail(); } catch (ConnectionException e) { } assertThat(client.isConnected(), is(false)); }
private void setTableSkipProperty( IMetaStoreClient msClient, String tbl, String val) throws Exception { Table table = msClient.getTable(ss.getCurrentDatabase(), tbl); table.getParameters().put(StatsUpdaterThread.SKIP_STATS_AUTOUPDATE_PROPERTY, val); msClient.alter_table(table.getDbName(), table.getTableName(), table); }
private void verifyStatsUpToDate(String tbl, List<String> cols, IMetaStoreClient msClient, String validWriteIds, boolean isUpToDate) throws Exception { Table table = msClient.getTable(ss.getCurrentCatalog(), ss.getCurrentDatabase(), tbl, validWriteIds); verifyStatsUpToDate(table.getParameters(), cols, isUpToDate); }
@Test(expected = MetaException.class) public void testAlterPartitionsMissingPartitionVals() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).build(metaStore.getConf()); Partition part1 = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1).get(0); client.alter_partitions(DB_NAME, TABLE_NAME, Lists.newArrayList(part, part1)); }
@Test(expected = MetaException.class) public void testAlterPartitionsWithEnvironmentCtxMissingPartitionVals() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).build(metaStore.getConf()); Partition part1 = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1).get(0); client.alter_partitions(DB_NAME, TABLE_NAME, Lists.newArrayList(part, part1), new EnvironmentContext()); }
@Test(expected = MetaException.class) public void testAlterPartitionsIncompletePartitionVals() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).addValue("2017").build(metaStore.getConf()); Partition part1 = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1).get(0); client.alter_partitions(DB_NAME, TABLE_NAME, Lists.newArrayList(part, part1)); }
@Test(expected = MetaException.class) public void testAlterPartitionsWithEnvironmentCtxIncompletePartitionVals() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).addValue("2017").build(metaStore.getConf()); Partition part1 = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1).get(0); client.alter_partitions(DB_NAME, TABLE_NAME, Lists.newArrayList(part, part1), new EnvironmentContext()); }
@Test(expected = InvalidOperationException.class) public void testAlterPartitionsWithEnvironmentCtxUnknownPartition() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).addValue("1111").addValue("11").addValue("11").build(metaStore.getConf()); Partition part1 = client.listPartitions(DB_NAME, TABLE_NAME, (short)-1).get(0); client.alter_partitions(DB_NAME, TABLE_NAME, Lists.newArrayList(part, part1), new EnvironmentContext()); }
@Test(expected = MetaException.class) public void testAlterPartitionMissingPartitionVals() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).build(metaStore.getConf()); client.alter_partition(DB_NAME, TABLE_NAME, part); }
@Test(expected = MetaException.class) public void testAlterPartitionIncompletePartitionVals() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).addValue("2017").build(metaStore.getConf()); client.alter_partition(DB_NAME, TABLE_NAME, part); }
private Table createTable(String dbName, String tableName, List<FieldSchema> partCols, List<FieldSchema> cols, String location) throws Exception { new TableBuilder() .setDbName(dbName) .setTableName(tableName) .setCols(cols) .setPartCols(partCols) .setLocation(location) .create(client, metaStore.getConf()); return client.getTable(dbName, tableName); }
@Test(expected = MetaException.class) public void testAlterPartitionWithEnvironmentCtxMissingPartitionVals() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).build(metaStore.getConf()); client.alter_partition(DB_NAME, TABLE_NAME, part, new EnvironmentContext()); }
@Test(expected = MetaException.class) public void testAlterPartitionWithEnvironmentCtxIncompletePartitionVals() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).addValue("2017").build(metaStore.getConf()); client.alter_partition(DB_NAME, TABLE_NAME, part, new EnvironmentContext()); }
@Test(expected = InvalidOperationException.class) public void testAlterPartitionUnknownPartition() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).addValue("1111").addValue("11").addValue("11").build(metaStore.getConf()); client.alter_partition(DB_NAME, TABLE_NAME, part); }
@Test(expected = InvalidOperationException.class) public void testAlterPartitionWithEnvironmentCtxUnknownPartition() throws Exception { createTable4PartColsParts(client); Table t = client.getTable(DB_NAME, TABLE_NAME); PartitionBuilder builder = new PartitionBuilder(); Partition part = builder.inTable(t).addValue("1111").addValue("11").addValue("11").build(metaStore.getConf()); client.alter_partition(DB_NAME, TABLE_NAME, part, new EnvironmentContext()); }