Java Code Examples for org.apache.hadoop.hive.metastore.MetaStoreUtils#isExternalTable()
The following examples show how to use
org.apache.hadoop.hive.metastore.MetaStoreUtils#isExternalTable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamoDBStorageHandler.java From emr-dynamodb-connector with Apache License 2.0 | 6 votes |
@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(); } }
Example 2
Source File: KuduStorageHandler.java From HiveKudu-Handler with Apache License 2.0 | 6 votes |
@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(); } } }
Example 3
Source File: KuduStorageHandler.java From HiveKudu-Handler with Apache License 2.0 | 6 votes |
@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(); } } }
Example 4
Source File: CassandraStorageHandler.java From Hive-Cassandra with Apache License 2.0 | 6 votes |
@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(); } } }
Example 5
Source File: CassandraStorageHandler.java From Hive-Cassandra with Apache License 2.0 | 5 votes |
@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(); } }
Example 6
Source File: JdbcStorageHandler.java From HiveJdbcStorageHandler with Apache License 2.0 | 5 votes |
@Override public void preCreateTable(Table tbl) throws MetaException { if(!MetaStoreUtils.isExternalTable(tbl)) { throw new MetaException("Table must be external."); } // TODO Auto-generated method stub }
Example 7
Source File: SMStorageHandler.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@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); } }
Example 8
Source File: KuduStorageHandler.java From HiveKudu-Handler with Apache License 2.0 | 4 votes |
@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(); } } }