/** * Check if the current user has access to a given database and table name. Throw * NoSuchObjectException if user has no access. When the db or table is filtered out, we don't need * to even fetch the partitions. Therefore this check ensures table-level security and * could improve performance when filtering partitions. * @param catName the catalog name * @param dbName the database name * @param tblName the table name contained in the database * @throws NoSuchObjectException if the database or table is filtered out */ private void checkDbAndTableFilters(final String catName, final String dbName, final String tblName) throws NoSuchObjectException, MetaException { FilterUtils.checkDbAndTableFilters( isClientFilterEnabled, filterHook, catName, dbName, tblName); }
List<String> filteredDb = filterDbNamesIfEnabled(isFilterEnabled, filterHook, Collections.singletonList(dbName)); filterTableNamesIfEnabled(isFilterEnabled, filterHook, catName, dbName, Collections.singletonList(tblName)); if (filteredTable.isEmpty()) {
@Override public Partition getPartition(String catName, String dbName, String tblName, List<String> partVals) throws TException { Partition p = client.get_partition(prependCatalogToDbName(catName, dbName, conf), tblName, partVals); return deepCopy(FilterUtils.filterPartitionIfEnabled(isClientFilterEnabled, filterHook, p)); }
@Override public List<Partition> listPartitions(String catName, String db_name, String tbl_name, int max_parts) throws TException { List<Partition> parts = client.get_partitions(prependCatalogToDbName(catName, db_name, conf), tbl_name, shrinkMaxtoShort(max_parts)); return deepCopyPartitions( FilterUtils.filterPartitionsIfEnabled(isClientFilterEnabled, filterHook, parts)); }
@Override public List<String> getAllTables(String catName, String dbName) throws TException { List<String> tableNames = client.get_all_tables( prependCatalogToDbName(catName, dbName, conf)); return FilterUtils.filterTableNamesIfEnabled(isClientFilterEnabled, filterHook, catName, dbName, tableNames); }
@Override public List<String> listPartitionNames(String catName, String dbName, String tableName, int maxParts) throws TException { List<String> partNames = client.get_partition_names( prependCatalogToDbName(catName, dbName, conf), tableName, shrinkMaxtoShort(maxParts)); return FilterUtils.filterPartitionNamesIfEnabled( isClientFilterEnabled, filterHook, catName, dbName, tableName, partNames); }
@Override public List<String> getDatabases(String catName, String databasePattern) throws TException { List<String> databases = client.get_databases(prependCatalogToDbName( catName, databasePattern, conf)); return FilterUtils.filterDbNamesIfEnabled(isClientFilterEnabled, filterHook, databases); }
FilterUtils.filterTablesIfEnabled(isServerFilterEnabled, filterHook, tables); } catch (MetaException | InvalidOperationException | UnknownDBException e) { ex = e;
@Override public List<TableMeta> getTableMeta(String catName, String dbPatterns, String tablePatterns, List<String> tableTypes) throws TException { List<TableMeta> tableMetas = client.get_table_meta(prependCatalogToDbName( catName, dbPatterns, conf), tablePatterns, tableTypes); return FilterUtils.filterTableMetasIfEnabled(isClientFilterEnabled, filterHook, catName,dbPatterns, tableMetas); }
@Override public List<String> getCatalogs() throws TException { GetCatalogsResponse rsp = client.get_catalogs(); return rsp == null ? null : FilterUtils.filterCatalogNamesIfEnabled(isClientFilterEnabled, filterHook, rsp.getNames()); }
@Override public Catalog getCatalog(String catName) throws TException { GetCatalogResponse rsp = client.get_catalog(new GetCatalogRequest(catName)); return rsp == null ? null : FilterUtils.filterCatalogIfEnabled(isClientFilterEnabled, filterHook, rsp.getCatalog()); }
@Override public List<Partition> listPartitionsWithAuthInfo(String catName, String dbName, String tableName, int maxParts, String userName, List<String> groupNames) throws TException { List<Partition> parts = client.get_partitions_with_auth(prependCatalogToDbName(catName, dbName, conf), tableName, shrinkMaxtoShort(maxParts), userName, groupNames); return deepCopyPartitions(FilterUtils.filterPartitionsIfEnabled(isClientFilterEnabled, filterHook, parts)); }
@Override public List<String> getTables(String catName, String dbName, String tablePattern) throws TException { List<String> tables = client.get_tables(prependCatalogToDbName(catName, dbName, conf), tablePattern); return FilterUtils.filterTableNamesIfEnabled(isClientFilterEnabled, filterHook, catName, dbName, tables); }
@Override public List<String> listPartitionNames(String catName, String db_name, String tbl_name, List<String> part_vals, int max_parts) throws TException { List<String> partNames = client.get_partition_names_ps(prependCatalogToDbName(catName, db_name, conf), tbl_name, part_vals, shrinkMaxtoShort(max_parts)); return FilterUtils.filterPartitionNamesIfEnabled( isClientFilterEnabled, filterHook, catName, db_name, tbl_name, partNames); }
@Override public List<String> getAllDatabases(String catName) throws TException { List<String> databases = client.get_databases(prependCatalogToDbName(catName, null, conf)); return FilterUtils.filterDbNamesIfEnabled(isClientFilterEnabled, filterHook, databases); }
@Override public List<Table> getTableObjectsByName(String catName, String dbName, List<String> tableNames) throws TException { GetTablesRequest req = new GetTablesRequest(dbName); req.setCatName(catName); req.setTblNames(tableNames); req.setCapabilities(version); List<Table> tabs = client.get_table_objects_by_name_req(req).getTables(); return deepCopyTables(FilterUtils.filterTablesIfEnabled(isClientFilterEnabled, filterHook, tabs)); }
@Override public List<TableMeta> get_table_meta(String dbnames, String tblNames, List<String> tblTypes) throws MetaException, NoSuchObjectException { List<TableMeta> t = null; String[] parsedDbName = parseDbName(dbnames, conf); startTableFunction("get_table_metas", parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames); Exception ex = null; try { t = getMS().getTableMeta(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tblNames, tblTypes); t = FilterUtils.filterTableMetasIfEnabled(isServerFilterEnabled, filterHook, parsedDbName[CAT_NAME], parsedDbName[DB_NAME], t); } catch (Exception e) { ex = e; throw newMetaException(e); } finally { endFunction("get_table_metas", t != null, ex); } return t; }
@Override public List<Partition> listPartitionsByFilter(String catName, String db_name, String tbl_name, String filter, int max_parts) throws TException { List<Partition> parts =client.get_partitions_by_filter(prependCatalogToDbName( catName, db_name, conf), tbl_name, filter, shrinkMaxtoShort(max_parts)); return deepCopyPartitions(FilterUtils.filterPartitionsIfEnabled(isClientFilterEnabled, filterHook, parts)); }
@Override public List<String> listTableNamesByFilter(String catName, String dbName, String filter, int maxTables) throws TException { List<String> tableNames = client.get_table_names_by_filter(prependCatalogToDbName(catName, dbName, conf), filter, shrinkMaxtoShort(maxTables)); return FilterUtils.filterTableNamesIfEnabled( isClientFilterEnabled, filterHook, catName, dbName, tableNames); }
@Override public Partition getPartitionWithAuthInfo(String catName, String dbName, String tableName, List<String> pvals, String userName, List<String> groupNames) throws TException { Partition p = client.get_partition_with_auth(prependCatalogToDbName(catName, dbName, conf), tableName, pvals, userName, groupNames); return deepCopy(FilterUtils.filterPartitionIfEnabled(isClientFilterEnabled, filterHook, p)); }