public NoSuchObjectException deepCopy() { return new NoSuchObjectException(this); }
@Override public Table filterTable(Table table) throws NoSuchObjectException { if (blockResults) { throw new NoSuchObjectException("Blocked access"); } return table; }
@Override public Database filterDatabase(Database dataBase) throws NoSuchObjectException { if (blockResults) { throw new NoSuchObjectException("Blocked access"); } return dataBase; }
@Override public Partition filterPartition(Partition partition) throws NoSuchObjectException { if (blockResults) { throw new NoSuchObjectException("Blocked access"); } return partition; }
/** * Verify that role with given name exists, if not throw exception * @param roleName * @throws NoSuchObjectException */ private void validateRole(String roleName) throws NoSuchObjectException { // if grantee is a role, check if it exists MRole granteeRole = getMRole(roleName); if (granteeRole == null) { throw new NoSuchObjectException("Role " + roleName + " does not exist"); } }
private boolean deleteTempTableColumnStats(String dbName, String tableName, String columnName) throws NoSuchObjectException { ColumnStatisticsObj deletedEntry = null; Map<String, ColumnStatisticsObj> ssTableColStats = getTempTableColumnStatsForTable(dbName, tableName); if (ssTableColStats != null) { deletedEntry = ssTableColStats.remove(columnName.toLowerCase()); } if (deletedEntry == null) { throw new NoSuchObjectException("Column stats doesn't exist for db=" + dbName + " temp table=" + tableName); } return true; }
@Override public Catalog getCatalog(String catalogName) throws NoSuchObjectException, MetaException { LOG.debug("Fetching catalog " + catalogName); MCatalog mCat = getMCatalog(catalogName); if (mCat == null) { throw new NoSuchObjectException("No catalog " + catalogName); } return mCatToCat(mCat); }
@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); }
/** * Gets the table object for a given table, throws if anything goes wrong. * @param dbName Database name. * @param tblName Table name. * @return Table object. */ private MTable ensureGetMTable(String catName, String dbName, String tblName) throws NoSuchObjectException, MetaException { MTable mtable = getMTable(catName, dbName, tblName); if (mtable == null) { throw new NoSuchObjectException("Specified catalog.database.table does not exist : " + TableName.getQualified(catName, dbName, tblName)); } return mtable; }
@Override public Database getDatabase(String name) throws TException { accessCount.incrementAndGet(); if (throwException) { throw new RuntimeException(); } if (!name.equals(TEST_DATABASE)) { throw new NoSuchObjectException(); } return new Database(TEST_DATABASE, null, null, null); }
@Override public Partition getPartition(String dbName, String tableName, List<String> partitionValues) throws TException { accessCount.incrementAndGet(); if (throwException) { throw new RuntimeException(); } if (!dbName.equals(TEST_DATABASE) || !tableName.equals(TEST_TABLE) || !ImmutableSet.of(TEST_PARTITION_VALUES1, TEST_PARTITION_VALUES2).contains(partitionValues)) { throw new NoSuchObjectException(); } return new Partition(null, TEST_DATABASE, TEST_TABLE, 0, 0, DEFAULT_STORAGE_DESCRIPTOR, ImmutableMap.of()); }
private boolean drop_partition_by_name_core(final RawStore ms, final String catName, final String db_name, final String tbl_name, final String part_name, final boolean deleteData, final EnvironmentContext envContext) throws TException, IOException { List<String> partVals; try { partVals = getPartValsFromName(ms, catName, db_name, tbl_name, part_name); } catch (InvalidObjectException e) { throw new NoSuchObjectException(e.getMessage()); } return drop_partition_common(ms, catName, db_name, tbl_name, partVals, deleteData, envContext); }
private boolean deleteTempTableColumnStatsForTable(String dbName, String tableName) throws NoSuchObjectException { Map<String, ColumnStatisticsObj> deletedEntry = getTempTableColumnStatsForTable(dbName, tableName); if (deletedEntry != null) { SessionState.get().getTempTableColStats().remove( StatsUtils.getFullyQualifiedTableName(dbName, tableName)); } else { throw new NoSuchObjectException("Column stats doesn't exist for db=" + dbName + " temp table=" + tableName); } return true; }
private boolean deleteTempTableColumnStatsForTable(String dbName, String tableName) throws NoSuchObjectException { Map<String, ColumnStatisticsObj> deletedEntry = getTempTableColumnStatsForTable(dbName, tableName); if (deletedEntry != null) { SessionState.get().getTempTableColStats().remove( StatsUtils.getFullyQualifiedTableName(dbName, tableName)); } else { throw new NoSuchObjectException("Column stats doesn't exist for db=" + dbName + " temp table=" + tableName); } return true; }
@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); } }); }
@Override public Catalog getCatalog(String catalogName) throws NoSuchObjectException, MetaException { // in case of event based cache update, cache will not be updated for catalog. if (!sharedCache.isCatalogCachePrewarmed() || canUseEvents) { return rawStore.getCatalog(catalogName); } Catalog cat = sharedCache.getCatalogFromCache(normalizeIdentifier(catalogName)); if (cat == null) { throw new NoSuchObjectException(); } return cat; }
/** * Fire a pre-event for read table operation, if there are any * pre-event listeners registered */ private void fireReadTablePreEvent(String catName, String dbName, String tblName) throws MetaException, NoSuchObjectException { if(preListeners.size() > 0) { // do this only if there is a pre event listener registered (avoid unnecessary // metastore api call) Table t = getMS().getTable(catName, dbName, tblName); if (t == null) { throw new NoSuchObjectException(TableName.getQualified(catName, dbName, tblName) + " table not found"); } firePreEvent(new PreReadTableEvent(t, this)); } }
@Override public Role getRole(String roleName) throws NoSuchObjectException { MRole mRole = this.getMRole(roleName); if (mRole == null) { throw new NoSuchObjectException(roleName + " role can not be found."); } Role ret = new Role(mRole.getRoleName(), mRole.getCreateTime(), mRole .getOwnerName()); return ret; }
@Override public Table getTable(String dbName, String tableName) throws TException { accessCount.incrementAndGet(); if (throwException) { throw new RuntimeException(); } if (!dbName.equals(TEST_DATABASE) || !tableName.equals(TEST_TABLE)) { throw new NoSuchObjectException(); } return new Table( TEST_TABLE, TEST_DATABASE, "", 0, 0, 0, DEFAULT_STORAGE_DESCRIPTOR, ImmutableList.of(new FieldSchema("key", "string", null)), null, "", "", TableType.MANAGED_TABLE.name()); }
@Override public Database getDatabase(String catName, String dbName) throws NoSuchObjectException { // in case of event based cache update, cache will be updated during commit. So within active transaction, read // directly from rawStore to avoid reading stale data as the data updated during same transaction will not be // updated in the cache. if (!sharedCache.isDatabaseCachePrewarmed() || (canUseEvents && rawStore.isActiveTransaction())) { return rawStore.getDatabase(catName, dbName); } dbName = dbName.toLowerCase(); Database db = sharedCache.getDatabaseFromCache(StringUtils.normalizeIdentifier(catName), StringUtils.normalizeIdentifier(dbName)); if (db == null) { throw new NoSuchObjectException(); } return db; }