本文整理汇总了Java中org.apache.hadoop.hive.metastore.MetaStoreUtils.isExternalTable方法的典型用法代码示例。如果您正苦于以下问题:Java MetaStoreUtils.isExternalTable方法的具体用法?Java MetaStoreUtils.isExternalTable怎么用?Java MetaStoreUtils.isExternalTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hive.metastore.MetaStoreUtils
的用法示例。
在下文中一共展示了MetaStoreUtils.isExternalTable方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preCreateTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void preCreateTable(Table table) throws MetaException {
DynamoDBClient client = createDynamoDBClient(table);
try {
boolean isExternal = MetaStoreUtils.isExternalTable(table);
if (!isExternal) {
throw new MetaException("Only EXTERNAL tables are supported for DynamoDB.");
}
String tableName = HiveDynamoDBUtil.getDynamoDBTableName(table.getParameters()
.get(DynamoDBConstants.TABLE_NAME), table.getTableName());
TableDescription tableDescription = client.describeTable(tableName);
checkTableStatus(tableDescription);
checkTableSchemaMapping(tableDescription, table);
checkTableSchemaType(tableDescription, table);
} finally {
client.close();
}
}
示例2: commitDropTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void commitDropTable(Table tbl, boolean deleteData)
throws MetaException {
KuduClient client = getKuduClient(tbl.getParameters().get(HiveKuduConstants.MASTER_ADDRESS_NAME));
String tablename = getKuduTableName(tbl);
boolean isExternal = MetaStoreUtils.isExternalTable(tbl);
try {
if (deleteData && !isExternal) {
client.deleteTable(tablename);
}
} catch (Exception ioe) {
throw new MetaException("Error dropping table:" +tablename);
} finally {
try {
client.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例3: rollbackCreateTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void rollbackCreateTable(Table tbl) throws MetaException {
KuduClient client = getKuduClient(tbl.getParameters().get(HiveKuduConstants.MASTER_ADDRESS_NAME));
String tablename = getKuduTableName(tbl);
boolean isExternal = MetaStoreUtils.isExternalTable(tbl);
try {
if ( client.tableExists(tablename) && !isExternal) {
client.deleteTable(tablename);
}
} catch (Exception ioe) {
throw new MetaException("Error dropping table while rollback of create table:" +tablename);
} finally {
try {
client.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例4: commitDropTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void commitDropTable(Table table, boolean deleteData) throws MetaException {
//TODO: Should this be implemented to drop the table and its data from cassandra
boolean isExternal = MetaStoreUtils.isExternalTable(table);
if (deleteData && !isExternal) {
CqlManager manager = new CqlManager(table);
try {
//open connection to cassandra
manager.openConnection();
//drop the table
manager.dropTable();
} finally {
manager.closeConnection();
}
}
}
示例5: commitDropTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void commitDropTable(Table table, boolean deleteData) throws MetaException {
//TODO: Should this be implemented to drop the table and its data from cassandra
boolean isExternal = MetaStoreUtils.isExternalTable(table);
if (deleteData && !isExternal) {
CassandraManager manager = new CassandraManager(table);
try {
//open connection to cassandra
manager.openConnection();
//drop the table
manager.dropTable();
} finally {
manager.closeConnection();
}
}
}
示例6: commitDropTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void commitDropTable(Table table, boolean deleteData) throws MetaException {
//TODO: Should this be implemented to drop the table and its data from cassandra
boolean isExternal = MetaStoreUtils.isExternalTable(table);
if (deleteData && !isExternal) {
CassandraManager manager = new CassandraManager(table);
try {
//open connection to cassandra
manager.openConnection();
//drop the table
manager.dropTable();
} finally {
manager.closeConnection();
}
}
}
示例7: preCreateTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void preCreateTable(Table table) throws MetaException {
boolean isExternal = MetaStoreUtils.isExternalTable(table);
if (!isExternal) {
throw new MetaException("Cassandra tables must be external.");
}
if (table.getSd().getLocation() != null) {
throw new MetaException("LOCATION may not be specified for Cassandra.");
}
CqlManager manager = new CqlManager(table);
try {
//open connection to cassandra
manager.openConnection();
if (!manager.doesKeyspaceExist()) {
logger.info("Keyspace doesnot exist. Creating keyspace {}", table.getDbName());
manager.createKeyspace();
}
//create the column family if it doesn't exist.
manager.createCFIfNotFound();
} finally {
manager.closeConnection();
}
}
示例8: preCreateTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void preCreateTable(Table table) throws MetaException {
boolean isExternal = MetaStoreUtils.isExternalTable(table);
if (!isExternal) {
throw new MetaException("Cassandra tables must be external.");
}
if (table.getSd().getLocation() != null) {
throw new MetaException("LOCATION may not be specified for Cassandra.");
}
CassandraManager manager = new CassandraManager(table);
try {
//open connection to cassandra
manager.openConnection();
KsDef ks = manager.getKeyspaceDesc();
//create the column family if it doesn't exist.
manager.createCFIfNotFound(ks);
} catch (NotFoundException e) {
manager.createKeyspaceWithColumns();
} finally {
manager.closeConnection();
}
}
示例9: preCreateTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void preCreateTable(Table table) throws MetaException {
boolean isExternal = MetaStoreUtils.isExternalTable(table);
if (!isExternal) {
throw new MetaException("Cassandra tables must be external.");
}
if (table.getSd().getLocation() != null) {
throw new MetaException("LOCATION may not be specified for Cassandra.");
}
CassandraManager manager = new CassandraManager(table);
try {
//open connection to cassandra
manager.openConnection();
KsDef ks = manager.getKeyspaceDesc();
//create the column family if it doesn't exist.
manager.createCFIfNotFound(ks);
} catch(NotFoundException e) {
manager.createKeyspaceWithColumns();
} finally {
manager.closeConnection();
}
}
示例10: preCreateTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void preCreateTable(Table tbl) throws MetaException {
if(!MetaStoreUtils.isExternalTable(tbl)) {
throw new MetaException("Table must be external.");
}
// TODO Auto-generated method stub
}
示例11: preCreateTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void preCreateTable(Table tbl) throws MetaException {
boolean isExternal = MetaStoreUtils.isExternalTable(tbl);
if (isExternal) {
Log.info("Creating External table for Splice...");
}
String inputTableName = tbl.getParameters().get(MRConstants.SPLICE_TABLE_NAME);
if (inputTableName == null)
throw new MetaException("Wrong param, you are missing " +
MRConstants.SPLICE_TABLE_NAME + " ? ");
// We can choose to support user define column mapping.
// But currently I don't think it is necessary
// We map all columns from Splice Table to Hive Table.
String connStr = tbl.getParameters().get(MRConstants.SPLICE_JDBC_STR);
if (connStr == null)
throw new MetaException("Wrong param, did you mean " +
MRConstants.SPLICE_JDBC_STR + " ? ");
if (sqlUtil == null)
sqlUtil = SMSQLUtil.getInstance(connStr);
if (inputTableName != null) {
inputTableName = inputTableName.trim();
checkTableExists(inputTableName);
}
}
示例12: isExternalTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
protected boolean isExternalTable(Table table) {
return MetaStoreUtils.isExternalTable(table);
}
示例13: preCreateTable
import org.apache.hadoop.hive.metastore.MetaStoreUtils; //导入方法依赖的package包/类
@Override
public void preCreateTable(Table tbl)
throws MetaException {
KuduClient client = getKuduClient(tbl.getParameters().get(HiveKuduConstants.MASTER_ADDRESS_NAME));
boolean isExternal = MetaStoreUtils.isExternalTable(tbl);
if (isExternal) {
//TODO: Check if Kudu table exists to allow external table.
//TODO: Check if column and types are compatible with existing Kudu table.
throw new MetaException("External Table to Kudu not yet supported.");
}
if (tbl.getSd().getLocation() != null) {
throw new MetaException("LOCATION may not be specified for Kudu");
}
String tablename = getKuduTableName(tbl);
try {
List<String> keyColumns = Arrays.asList(tbl.getParameters().get(HiveKuduConstants.KEY_COLUMNS).split("\\s*,\\s*"));
List<FieldSchema> tabColumns = tbl.getSd().getCols();
int numberOfCols = tabColumns.size();
List<ColumnSchema> columns = new ArrayList<>(numberOfCols);
for (FieldSchema fields : tabColumns) {
ColumnSchema columnSchema = new ColumnSchema
.ColumnSchemaBuilder(fields.getName(), HiveKuduBridgeUtils.hiveTypeToKuduType(fields.getType()))
.key(keyColumns.contains(fields.getName()))
.nullable(!keyColumns.contains(fields.getName()))
.build();
columns.add(columnSchema);
}
Schema schema = new Schema(columns);
printSchema(schema);
CreateTableOptions createTableOptions = new CreateTableOptions();
//TODO : add support for partition and buckets
client.createTable(tablename, schema, createTableOptions);
} catch (Exception se) {
throw new MetaException("Error creating Kudu table: " + tablename + ":" + se);
} finally {
try {
client.shutdown();
} catch (Exception e) {
e.printStackTrace();
}
}
}