org.apache.hadoop.hive.metastore.api.NoSuchObjectException Java Examples
The following examples show how to use
org.apache.hadoop.hive.metastore.api.NoSuchObjectException.
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: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 7 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> listPartitionsWithAuthInfo(String database, String table, List<String> partVals, short maxParts, String user, List<String> groups) throws MetaException, TException, NoSuchObjectException { List<org.apache.hadoop.hive.metastore.api.Partition> partitions = listPartitions(database, table, partVals, maxParts); for (org.apache.hadoop.hive.metastore.api.Partition p : partitions) { HiveObjectRef obj = new HiveObjectRef(); obj.setObjectType(HiveObjectType.PARTITION); obj.setDbName(database); obj.setObjectName(table); obj.setPartValues(p.getValues()); org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet set; try { set = get_privilege_set(obj, user, groups); } catch (MetaException e) { logger.info(String.format("No privileges found for user: %s, " + "groups: [%s]", user, LoggingHelper.concatCollectionToStringForLogging(groups, ","))); set = new org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet(); } p.setPrivileges(set); } return partitions; }
Example #2
Source File: MockThriftMetastoreClient.java From presto with Apache License 2.0 | 6 votes |
@Override public List<ColumnStatisticsObj> getTableColumnStatistics(String databaseName, String tableName, List<String> columnNames) throws TException { accessCount.incrementAndGet(); if (throwException) { throw new RuntimeException(); } if (!databaseName.equals(TEST_DATABASE) || !tableName.equals(TEST_TABLE) || !columnNames.equals(ImmutableList.of(TEST_COLUMN))) { throw new NoSuchObjectException(); } return ImmutableList.of(createTestStats()); }
Example #3
Source File: MockThriftMetastoreClient.java From presto with Apache License 2.0 | 6 votes |
@Override public List<Partition> getPartitionsByNames(String dbName, String tableName, List<String> names) throws TException { accessCount.incrementAndGet(); if (throwException) { throw new RuntimeException(); } if (!dbName.equals(TEST_DATABASE) || !tableName.equals(TEST_TABLE) || !ImmutableSet.of(TEST_PARTITION1, TEST_PARTITION2).containsAll(names)) { throw new NoSuchObjectException(); } return Lists.transform(names, name -> { try { return new Partition(ImmutableList.copyOf(Warehouse.getPartValuesFromPartName(name)), TEST_DATABASE, TEST_TABLE, 0, 0, DEFAULT_STORAGE_DESCRIPTOR, ImmutableMap.of()); } catch (MetaException e) { throw new RuntimeException(e); } }); }
Example #4
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> listPartitionsWithAuthInfo(String database, String table, short maxParts, String user, List<String> groups) throws MetaException, TException, NoSuchObjectException { List<org.apache.hadoop.hive.metastore.api.Partition> partitions = listPartitions(database, table, maxParts); for (org.apache.hadoop.hive.metastore.api.Partition p : partitions) { HiveObjectRef obj = new HiveObjectRef(); obj.setObjectType(HiveObjectType.PARTITION); obj.setDbName(database); obj.setObjectName(table); obj.setPartValues(p.getValues()); org.apache.hadoop.hive.metastore.api.PrincipalPrivilegeSet set = this.get_privilege_set(obj, user, groups); p.setPrivileges(set); } return partitions; }
Example #5
Source File: HiveShimV1.java From flink with Apache License 2.0 | 6 votes |
@Override public Function getFunction(IMetaStoreClient client, String dbName, String functionName) throws NoSuchObjectException, TException { try { // hive-1.x doesn't throw NoSuchObjectException if function doesn't exist, instead it throws a MetaException return client.getFunction(dbName, functionName); } catch (MetaException e) { // need to check the cause and message of this MetaException to decide whether it should actually be a NoSuchObjectException if (e.getCause() instanceof NoSuchObjectException) { throw (NoSuchObjectException) e.getCause(); } if (e.getMessage().startsWith(NoSuchObjectException.class.getSimpleName())) { throw new NoSuchObjectException(e.getMessage()); } throw e; } }
Example #6
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Override public boolean dropIndex(String dbName, String tblName, String name, boolean deleteData) throws NoSuchObjectException, MetaException, TException { Index indexToDrop = getIndex(dbName, tblName, name); String indexTableName = indexToDrop.getIndexTableName(); // Drop the index metadata org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, tblName); Map<String, String> parameters = originTable.getParameters(); String indexTableObjectName = INDEX_PREFIX + name; if (!parameters.containsKey(indexTableObjectName)) { throw new NoSuchObjectException("can not find Index: " + name); } parameters.remove(indexTableObjectName); alter_table(dbName, tblName, originTable); // Now drop the data associated with the table used to hold the index data if(indexTableName != null && indexTableName.length() > 0) { dropTable(dbName, indexTableName, deleteData, true); } return true; }
Example #7
Source File: MetastoreClientIndexIntegrationTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Test (expected = NoSuchObjectException.class) public void listIndexesInvalidWithUnknownTable() throws TException { Index index2 = TestObjects.getTestHiveIndex(hiveDB.getName()); Index index3 = TestObjects.getTestHiveIndex(hiveDB.getName()); Table hiveIndexTable2 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName()); Table hiveIndexTable3 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName()); index2.setOrigTableName(hiveTable.getTableName()); index2.setIndexTableName(hiveIndexTable2.getTableName()); index3.setOrigTableName(hiveTable.getTableName()); index3.setIndexTableName(hiveIndexTable3.getTableName()); metastoreClient.createIndex(hiveIndex, hiveIndexTable); metastoreClient.createIndex(index2, hiveIndexTable2); metastoreClient.createIndex(index3, hiveIndexTable3); metastoreClient.listIndexes(hiveDB.getName(), invalidTable, (short) 2); }
Example #8
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Override public boolean dropIndex(String dbName, String tblName, String name, boolean deleteData) throws NoSuchObjectException, MetaException, TException { Index indexToDrop = getIndex(dbName, tblName, name); String indexTableName = indexToDrop.getIndexTableName(); // Drop the index metadata org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, tblName); Map<String, String> parameters = originTable.getParameters(); String indexTableObjectName = INDEX_PREFIX + name; if (!parameters.containsKey(indexTableObjectName)) { throw new NoSuchObjectException("can not find Index: " + name); } parameters.remove(indexTableObjectName); alter_table(dbName, tblName, originTable); // Now drop the data associated with the table used to hold the index data if(indexTableName != null && indexTableName.length() > 0) { dropTable(dbName, indexTableName, deleteData, true); } return true; }
Example #9
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
private void performDropPartitionPostProcessing(String dbName, String tblName, org.apache.hadoop.hive.metastore.api.Partition partition, boolean deleteData, boolean ifPurge) throws MetaException, NoSuchObjectException, TException { if (deleteData && partition.getSd() != null && partition.getSd().getLocation() != null) { Path partPath = new Path(partition.getSd().getLocation()); org.apache.hadoop.hive.metastore.api.Table table = getTable(dbName, tblName); if (isExternalTable(table)){ //Don't delete external table data return; } boolean mustPurge = isMustPurge(table, ifPurge); wh.deleteDir(partPath, true, mustPurge); try { List<String> values = partition.getValues(); deleteParentRecursive(partPath.getParent(), values.size() - 1, mustPurge); } catch (IOException e) { throw new MetaException(e.getMessage()); } } }
Example #10
Source File: MetastoreClientIndexIntegrationTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 6 votes |
@Test (expected = NoSuchObjectException.class) public void listIndexNameInvalidWithUnknownDb() throws TException { Index index2 = TestObjects.getTestHiveIndex(hiveDB.getName()); Index index3 = TestObjects.getTestHiveIndex(hiveDB.getName()); Table hiveIndexTable2 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName()); Table hiveIndexTable3 = CatalogToHiveConverter.convertTable(getTestTable(), hiveDB.getName()); index2.setOrigTableName(hiveTable.getTableName()); index2.setIndexTableName(hiveIndexTable2.getTableName()); index3.setOrigTableName(hiveTable.getTableName()); index3.setIndexTableName(hiveIndexTable3.getTableName()); metastoreClient.createIndex(hiveIndex, hiveIndexTable); metastoreClient.createIndex(index2, hiveIndexTable2); metastoreClient.createIndex(index3, hiveIndexTable3); metastoreClient.listIndexNames(invalidDatabase, hiveTable.getTableName(), (short) 2); }
Example #11
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> listPartitions( String databaseName, String tableName, List<String> values, short max ) throws NoSuchObjectException, MetaException, TException { String expression = null; if (values != null) { org.apache.hadoop.hive.metastore.api.Table table = getTable(databaseName, tableName); expression = ExpressionHelper.buildExpressionFromPartialSpecification(table, values); } return glueMetastoreClientDelegate.getPartitions(databaseName, tableName, expression, (long) max); }
Example #12
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> dropPartitions( String dbName, String tblName, List<ObjectPair<Integer, byte[]>> partExprs, boolean deleteData, boolean ifExists, boolean needResults ) throws NoSuchObjectException, MetaException, TException { return dropPartitions_core(dbName, tblName, partExprs, deleteData, false); }
Example #13
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> dropPartitions( String dbName, String tblName, List<ObjectPair<Integer, byte[]>> partExprs, boolean deleteData, boolean ignoreProtection, boolean ifExists, boolean needResult) throws NoSuchObjectException, MetaException, TException { return dropPartitions_core(dbName, tblName, partExprs, deleteData, false); }
Example #14
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public List<String> listPartitionNames(String dbName, String tblName, short max) throws MetaException, TException { try { return listPartitionNames(dbName, tblName, null, max); } catch (NoSuchObjectException e) { // For compatibility with Hive 1.0.0 return Collections.emptyList(); } }
Example #15
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> listPartitions( String databaseName, String tableName, List<String> values, short max ) throws NoSuchObjectException, MetaException, TException { String expression = null; if (values != null) { org.apache.hadoop.hive.metastore.api.Table table = getTable(databaseName, tableName); expression = ExpressionHelper.buildExpressionFromPartialSpecification(table, values); } return glueMetastoreClientDelegate.getPartitions(databaseName, tableName, expression, (long) max); }
Example #16
Source File: ThriftHiveMetastore.java From presto with Apache License 2.0 | 5 votes |
private static boolean defaultIsValidExceptionalResponse(Exception exception) { if (exception instanceof NoSuchObjectException) { return true; } if (exception.toString().contains("AccessControlException")) { // e.g. org.apache.hadoop.hive.metastore.api.MetaException: org.apache.hadoop.security.AccessControlException: Permission denied: ... return true; } return false; }
Example #17
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public void createIndex(Index index, org.apache.hadoop.hive.metastore.api.Table indexTable) throws InvalidObjectException, MetaException, NoSuchObjectException, TException, org.apache.hadoop.hive.metastore.api.AlreadyExistsException { boolean dirCreated = glueMetastoreClientDelegate.validateNewTableAndCreateDirectory(indexTable); boolean indexTableCreated = false; String dbName = index.getDbName(); String indexTableName = index.getIndexTableName(); String originTableName = index.getOrigTableName(); Path indexTablePath = new Path(indexTable.getSd().getLocation()); Table catalogIndexTableObject = HiveToCatalogConverter.convertIndexToTableObject(index); String indexTableObjectName = INDEX_PREFIX + index.getIndexName(); try { org.apache.hadoop.hive.metastore.api.Table originTable = getTable(dbName, originTableName); Map<String, String> parameters = originTable.getParameters(); if (parameters.containsKey(indexTableObjectName)){ throw new org.apache.hadoop.hive.metastore.api.AlreadyExistsException("Index: " + index.getIndexName() + " already exist"); } createTable(indexTable); indexTableCreated = true; originTable.getParameters().put(indexTableObjectName, catalogTableToString(catalogIndexTableObject)); alter_table(dbName, originTableName, originTable); } catch (Exception e) { if (dirCreated){ wh.deleteDir(indexTablePath, true); } if (indexTableCreated) { dropTable(dbName, indexTableName); } String msg = "Unable to create index: "; logger.error(msg, e); if (e instanceof TException) { throw e; } else { throw new MetaException(msg + e); } } }
Example #18
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public List<String> listPartitionNames(String dbName, String tblName, short max) throws MetaException, TException { try { return listPartitionNames(dbName, tblName, null, max); } catch (NoSuchObjectException e) { // For compatibility with Hive 1.0.0 return Collections.emptyList(); } }
Example #19
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public void createTableWithConstraints( org.apache.hadoop.hive.metastore.api.Table table, List<SQLPrimaryKey> primaryKeys, List<SQLForeignKey> foreignKeys ) throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException, TException { glueMetastoreClientDelegate.createTableWithConstraints(table, primaryKeys, foreignKeys); }
Example #20
Source File: MockThriftMetastoreClient.java From presto with Apache License 2.0 | 5 votes |
@Override public List<String> getPartitionNamesFiltered(String dbName, String tableName, List<String> partValues) throws TException { accessCount.incrementAndGet(); if (throwException) { throw new RuntimeException(); } if (!dbName.equals(TEST_DATABASE) || !tableName.equals(TEST_TABLE)) { throw new NoSuchObjectException(); } return ImmutableList.of(TEST_PARTITION1, TEST_PARTITION2); }
Example #21
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
private Path getDestinationPathForRename(String dbName, org.apache.hadoop.hive.metastore.api.Table tbl, org.apache.hadoop.hive.metastore.api.Partition newPartition) throws InvalidOperationException, MetaException, TException { try { Path destPath = new Path(hiveShims.getDefaultTablePath(getDatabase(dbName), tbl.getTableName(), wh), Warehouse.makePartName(tbl.getPartitionKeys(), newPartition.getValues())); return constructRenamedPath(destPath, new Path(newPartition.getSd().getLocation())); } catch (NoSuchObjectException e) { throw new InvalidOperationException( "Unable to change partition or table. Database " + dbName + " does not exist" + " Check metastore logs for detailed stack." + e.getMessage()); } }
Example #22
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public void markPartitionForEvent( String dbName, String tblName, Map<String, String> partKVs, PartitionEventType eventType ) throws MetaException, NoSuchObjectException, TException, UnknownTableException, UnknownDBException, UnknownPartitionException, InvalidPartitionException { glueMetastoreClientDelegate.markPartitionForEvent(dbName, tblName, partKVs, eventType); }
Example #23
Source File: MetastoreClientIndexIntegrationTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Test (expected = NoSuchObjectException.class) public void alterIndexInvalidWithUnknownDatabase() throws TException { metastoreClient.createIndex(hiveIndex, hiveIndexTable); Index newIndex = TestObjects.getTestHiveIndex(hiveDB.getName()); metastoreClient.alter_index(invalidDatabase, hiveTable.getTableName(), hiveIndex.getIndexName(), newIndex); }
Example #24
Source File: MetastoreClientIndexIntegrationTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Test (expected = NoSuchObjectException.class) public void alterIndexInvalidWithUnknownTable() throws TException { metastoreClient.createIndex(hiveIndex, hiveIndexTable); Index newIndex = TestObjects.getTestHiveIndex(hiveDB.getName()); newIndex.setOrigTableName(hiveTable.getTableName()); newIndex.setIndexTableName(hiveIndexTable.getTableName()); metastoreClient.alter_index(hiveDB.getName(), invalidTable, hiveIndex.getIndexName(), newIndex); }
Example #25
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public org.apache.hadoop.hive.metastore.api.Partition exchange_partition( Map<String, String> partitionSpecs, String srcDb, String srcTbl, String dstDb, String dstTbl ) throws MetaException, NoSuchObjectException, InvalidObjectException, TException { return glueMetastoreClientDelegate.exchangePartition(partitionSpecs, srcDb, srcTbl, dstDb, dstTbl); }
Example #26
Source File: MetastoreClientIndexIntegrationTest.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Test (expected = NoSuchObjectException.class) public void dropIndexInvalidWithUnknownDataBase() throws TException{ metastoreClient.createIndex(hiveIndex, hiveIndexTable); assertTrue(indexExist(hiveDB.getName(), hiveTable.getTableName(), hiveIndex.getIndexName())); metastoreClient.dropIndex(invalidDatabase,hiveTable.getTableName(), hiveIndex.getIndexName(), false); }
Example #27
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public void dropConstraint( String dbName, String tblName, String constraintName ) throws MetaException, NoSuchObjectException, TException { glueMetastoreClientDelegate.dropConstraint(dbName, tblName, constraintName); }
Example #28
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public Map<String, List<ColumnStatisticsObj>> getPartitionColumnStatistics( String dbName, String tableName, List<String> partitionNames, List<String> columnNames ) throws NoSuchObjectException, MetaException, TException { return glueMetastoreClientDelegate.getPartitionColumnStatistics(dbName, tableName, partitionNames, columnNames); }
Example #29
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public List<org.apache.hadoop.hive.metastore.api.Partition> exchange_partitions( Map<String, String> partitionSpecs, String sourceDb, String sourceTbl, String destDb, String destTbl ) throws MetaException, NoSuchObjectException, InvalidObjectException, TException { return glueMetastoreClientDelegate.exchangePartitions(partitionSpecs, sourceDb, sourceTbl, destDb, destTbl); }
Example #30
Source File: AWSCatalogMetastoreClient.java From aws-glue-data-catalog-client-for-apache-hive-metastore with Apache License 2.0 | 5 votes |
@Override public boolean deleteTableColumnStatistics( String dbName, String tableName, String colName ) throws NoSuchObjectException, MetaException, InvalidObjectException, TException, org.apache.hadoop.hive.metastore.api.InvalidInputException { return glueMetastoreClientDelegate.deleteTableColumnStatistics(dbName, tableName, colName); }