Search in sources :

Example 66 with TableBuilder

use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.

the class TestHiveMetaStore method createTable.

/**
 * Creates a simple table under specified database
 * @param dbName    the database name that the table will be created under
 * @param tableName the table name to be created
 */
private void createTable(String dbName, String tableName) throws TException {
    Table t = new TableBuilder().setDbName(dbName).setTableName(tableName).addCol("foo", "string").addCol("bar", "string").build();
    client.createTable(t);
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) TableBuilder(org.apache.hadoop.hive.metastore.client.builder.TableBuilder)

Example 67 with TableBuilder

use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.

the class TestAddPartitions method createExternalTable.

private void createExternalTable(String tableName, String location) throws Exception {
    Table table = new TableBuilder().setDbName(DB_NAME).setTableName(tableName).addCol("test_id", "int", "test col id").addCol("test_value", DEFAULT_COL_TYPE, "test col value").addPartCol(YEAR_COL_NAME, DEFAULT_COL_TYPE).addTableParam("EXTERNAL", "TRUE").setLocation(location).build();
    client.createTable(table);
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) TableBuilder(org.apache.hadoop.hive.metastore.client.builder.TableBuilder)

Example 68 with TableBuilder

use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.

the class TestAddPartitionsFromPartSpec method createTable.

private Table createTable(String dbName, String tableName, List<FieldSchema> partCols, String location) throws Exception {
    Table table = new TableBuilder().setDbName(dbName).setTableName(tableName).addCol("test_id", "int", "test col id").addCol("test_value", "string", "test col value").addTableParam("partTestTableParamKey", "partTestTableParamValue").setPartCols(partCols).addStorageDescriptorParam("partTestSDParamKey", "partTestSDParamValue").setSerdeName(tableName).setStoredAsSubDirectories(false).addSerdeParam("partTestSerdeParamKey", "partTestSerdeParamValue").setLocation(location).build();
    client.createTable(table);
    return client.getTable(dbName, tableName);
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) TableBuilder(org.apache.hadoop.hive.metastore.client.builder.TableBuilder)

Example 69 with TableBuilder

use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.

the class TestAppendPartitions method createTable.

private Table createTable(String tableName, List<FieldSchema> partCols, Map<String, String> tableParams, String tableType, String location) throws Exception {
    Table table = new TableBuilder().setDbName(DB_NAME).setTableName(tableName).addCol("test_id", "int", "test col id").addCol("test_value", "string", "test col value").setPartCols(partCols).setTableParams(tableParams).setType(tableType).setLocation(location).build();
    client.createTable(table);
    return client.getTable(DB_NAME, tableName);
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) TableBuilder(org.apache.hadoop.hive.metastore.client.builder.TableBuilder)

Example 70 with TableBuilder

use of org.apache.hadoop.hive.metastore.client.builder.TableBuilder in project hive by apache.

the class TestSessionHiveMetastoreClientAlterPartitionsTempTable method createTestTable.

@Override
protected Table createTestTable(IMetaStoreClient client, String dbName, String tableName, List<String> partCols, boolean setPartitionLevelPrivilages) throws Exception {
    TableBuilder builder = new TableBuilder().setDbName(dbName).setTableName(tableName).addCol("id", "int").addCol("name", "string").setTemporary(true);
    partCols.forEach(col -> builder.addPartCol(col, "string"));
    Table table = builder.build(getMetaStore().getConf());
    if (setPartitionLevelPrivilages) {
        table.putToParameters(PART_PRIV, "true");
    }
    client.createTable(table);
    return table;
}
Also used : Table(org.apache.hadoop.hive.metastore.api.Table) TableBuilder(org.apache.hadoop.hive.metastore.client.builder.TableBuilder)

Aggregations

TableBuilder (org.apache.hadoop.hive.metastore.client.builder.TableBuilder)136 Table (org.apache.hadoop.hive.metastore.api.Table)111 Test (org.junit.Test)92 DatabaseBuilder (org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder)81 Database (org.apache.hadoop.hive.metastore.api.Database)40 Partition (org.apache.hadoop.hive.metastore.api.Partition)36 NoSuchObjectException (org.apache.hadoop.hive.metastore.api.NoSuchObjectException)35 PartitionBuilder (org.apache.hadoop.hive.metastore.client.builder.PartitionBuilder)33 MetastoreCheckinTest (org.apache.hadoop.hive.metastore.annotation.MetastoreCheckinTest)31 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)30 ArrayList (java.util.ArrayList)28 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)27 SourceTable (org.apache.hadoop.hive.metastore.api.SourceTable)25 CatalogBuilder (org.apache.hadoop.hive.metastore.client.builder.CatalogBuilder)23 Path (org.apache.hadoop.fs.Path)19 Catalog (org.apache.hadoop.hive.metastore.api.Catalog)19 Type (org.apache.hadoop.hive.metastore.api.Type)19 InvalidOperationException (org.apache.hadoop.hive.metastore.api.InvalidOperationException)17 TException (org.apache.thrift.TException)16 IOException (java.io.IOException)15