boolean first = true; if (isSetId()) { sb.append("id:"); sb.append(this.id);
List<Object> list = new ArrayList<Object>(); boolean present_id = true && (isSetId()); list.add(present_id); if (present_id)
if (struct.isSetId()) { oprot.writeFieldBegin(ID_FIELD_DESC); oprot.writeI64(struct.id);
if (tbl.isSetId()) { throw new InvalidObjectException("Id shouldn't be set but table " + tbl.getDbName() + "." + tbl.getTableName() + "has the Id set to "
@Test public void testCreateAndGetTableWithDriver() throws Exception { String dbName = "createDb"; String tblName = "createTbl"; client.dropTable(dbName, tblName); silentDropDatabase(dbName); new DatabaseBuilder() .setName(dbName) .create(client, conf); createTable(dbName, tblName); Table tblRead = client.getTable(dbName, tblName); Assert.assertTrue(tblRead.isSetId()); long firstTableId = tblRead.getId(); createTable(dbName, tblName + "_2"); Table tblRead2 = client.getTable(dbName, tblName + "_2"); Assert.assertTrue(tblRead2.isSetId()); Assert.assertNotEquals(firstTableId, tblRead2.getId()); }
return isSetId(); case TABLE_NAME: return isSetTableName();
Assert.assertTrue(table.getTTable().isSetId()); table.getTTable().unsetId();
Assert.assertTrue(tbl.isSetId()); tbl.unsetId();
@Test public void testAlterTable() throws Exception { Table originalTable = testTables[2]; String originalTableName = originalTable.getTableName(); String originalDatabase = originalTable.getDbName(); Table newTable = getTableWithAllParametersSet(); newTable.setTableName(originalTableName); newTable.setDbName(originalDatabase); // Partition keys can not be set, but getTableWithAllParametersSet is added one, so remove for // this test newTable.setPartitionKeys(originalTable.getPartitionKeys()); client.alter_table(originalDatabase, originalTableName, newTable); Table alteredTable = client.getTable(originalDatabase, originalTableName); // The extra parameters will be added on server side, so check that the required ones are // present for(String key: newTable.getParameters().keySet()) { Assert.assertEquals("parameters are present", newTable.getParameters().get(key), alteredTable.getParameters().get(key)); } // The parameters are checked manually, so do not check them newTable.setParameters(alteredTable.getParameters()); // Some of the data is set on the server side, so reset those newTable.setCreateTime(alteredTable.getCreateTime()); newTable.setCreationMetadata(alteredTable.getCreationMetadata()); newTable.setWriteId(alteredTable.getWriteId()); Assert.assertTrue(alteredTable.isSetId()); alteredTable.unsetId(); Assert.assertEquals("The table data should be the same", newTable, alteredTable); }
table.setWriteId(createdTable.getWriteId()); Assert.assertTrue(createdTable.isSetId()); createdTable.unsetId(); Assert.assertEquals("create/get table data", table, createdTable);
private Table createTestTable() throws HiveException, AlreadyExistsException { Database db = new Database(); db.setName(dbName); hive.createDatabase(db, true); Table table = new Table(dbName, tableName); table.setDbName(dbName); table.setInputFormatClass(TextInputFormat.class); table.setOutputFormatClass(HiveIgnoreKeyTextOutputFormat.class); table.setPartCols(partCols); hive.createTable(table); table = hive.getTable(dbName, tableName); Assert.assertTrue(table.getTTable().isSetId()); table.getTTable().unsetId(); for (Map<String, String> partSpec : parts) { hive.createPartition(table, partSpec); } return table; }
Assert.assertTrue(ft.getTTable().isSetId()); ft.getTTable().unsetId();
Assert.assertTrue(tbl2.isSetId()); assertEquals(tbl2.getDbName(), dbName); assertEquals(tbl2.getTableName(), tblName);
createTable(hmsc, true); Table table = hmsc.getTable(dbName, tableName); Assert.assertTrue(table.isSetId()); table.unsetId(); populatePartitions(hmsc, table, Arrays.asList("isLocatedInTablePath", "isLocatedOutsideTablePath"));