private boolean is_table_exists(RawStore ms, String catName, String dbname, String name) throws MetaException { return (ms.getTable(catName, dbname, name, null) != null); }
Table tbl = sharedCache.getTableFromCache(catName, dbName, tblName); if (tbl == null) { tbl = rawStore.getTable(catName, dbName, tblName);
public Table get_table_core(final String catName, final String dbname, final String name, final String writeIdList, boolean getColumnStats) throws MetaException, NoSuchObjectException { Table t = null; try { t = getMS().getTable(catName, dbname, name, writeIdList); if (t == null) { throw new NoSuchObjectException(TableName.getQualified(catName, dbname, name) + " table not found"); } // If column statistics was requested and is valid fetch it. if (getColumnStats) { ColumnStatistics colStats = getMS().getTableColumnStatistics(catName, dbname, name, StatsSetupConst.getColumnsHavingStats(t.getParameters()), writeIdList); if (colStats != null) { t.setColStats(colStats); } } } catch (Exception e) { throwMetaException(e); } return t; }
private List<String> getPartValsFromName(RawStore ms, String catName, String dbName, String tblName, String partName) throws MetaException, InvalidObjectException { Table t = ms.getTable(catName, dbName, tblName, null); if (t == null) { throw new InvalidObjectException(dbName + "." + tblName + " table not found"); } return getPartValsFromName(t, partName); }
private void updateTableColStats(RawStore rawStore, String catName, String dbName, String tblName) { boolean committed = false; rawStore.openTransaction(); try { Table table = rawStore.getTable(catName, dbName, tblName); if (!table.isSetPartitionKeys()) { List<String> colNames = MetaStoreUtils.getColumnNamesForTable(table); Deadline.startTimer("getTableColumnStatistics"); ColumnStatistics tableColStats = rawStore.getTableColumnStatistics(catName, dbName, tblName, colNames); Deadline.stopTimer(); if (tableColStats != null) { sharedCache.refreshTableColStatsInCache(StringUtils.normalizeIdentifier(catName), StringUtils.normalizeIdentifier(dbName), StringUtils.normalizeIdentifier(tblName), tableColStats.getStatsObj()); // Update the table to get consistent stats state. sharedCache.alterTableInCache(catName, dbName, tblName, table); } } committed = rawStore.commitTransaction(); } catch (MetaException | NoSuchObjectException e) { LOG.info("Unable to refresh table column stats for table: " + tblName, e); } finally { if (!committed) { sharedCache.removeAllTableColStatsFromCache(catName, dbName, tblName); rawStore.rollbackTransaction(); } } }
/** * Find the table being compacted * @param ci compaction info returned from the compaction queue * @return metastore table * @throws org.apache.hadoop.hive.metastore.api.MetaException if the table cannot be found. */ protected Table resolveTable(CompactionInfo ci) throws MetaException { try { return rs.getTable(ci.dbname, ci.tableName); } catch (MetaException e) { LOG.error("Unable to find table " + ci.getFullTableName() + ", " + e.getMessage()); throw e; } }
@Override Table resolveTable(CompactionInfo ci) throws MetaException { try { return rs.getTable(getDefaultCatalog(conf), ci.dbname, ci.tableName); } catch (MetaException e) { LOG.error("Unable to find table " + ci.getFullTableName() + ", " + e.getMessage()); throw e; } }
private Table getTable(String catName, String dbName, String tableName, String writeIdList) throws MetaException, InvalidObjectException { Table t = getMS().getTable(catName, dbName, tableName, writeIdList); if (t == null) { throw new InvalidObjectException(TableName.getQualified(catName, dbName, tableName) + " table not found"); } return t; }
private void updateTables(RawStore rawStore, String catName, String dbName) { List<Table> tables = new ArrayList<>(); try { List<String> tblNames = rawStore.getAllTables(catName, dbName); for (String tblName : tblNames) { if (!shouldCacheTable(catName, dbName, tblName)) { continue; } Table table = rawStore.getTable(StringUtils.normalizeIdentifier(catName), StringUtils.normalizeIdentifier(dbName), StringUtils.normalizeIdentifier(tblName)); tables.add(table); } sharedCache.refreshTablesInCache(catName, dbName, tables); } catch (MetaException e) { LOG.debug("Unable to refresh cached tables for database: " + dbName, e); } }
/** * 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)); } }
if (isAnalyzeTableInProgress(fullTableName)) return null; String cat = fullTableName.getCat(), db = fullTableName.getDb(), tbl = fullTableName.getTable(); Table table = rs.getTable(cat, db, tbl); LOG.debug("Processing table {}", table);
private static void updateTableAggregatePartitionColStats(RawStore rawStore, String catName, String dbName, String tblName) { try { Table table = rawStore.getTable(catName, dbName, tblName); List<String> partNames = rawStore.listPartitionNames(catName, dbName, tblName, (short) -1); List<String> colNames = MetaStoreUtils.getColumnNamesForTable(table);
getMS().openTransaction(); try { Table table = getMS().getTable(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
if (!listeners.isEmpty()) { if (table == null) { table = getMS().getTable(catName, db_name, tbl_name, null);
table = getMS().getTable(catName, db_name, tbl_name, null);
try { List<String> partVals = getPartValsFromName(getMS(), parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName, convertedPartName); Table table = getMS().getTable(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], tableName);
private void updateTablePartitionColStats(RawStore rawStore, String catName, String dbName, String tblName) { boolean committed = false; rawStore.openTransaction(); try { Table table = rawStore.getTable(catName, dbName, tblName); List<String> colNames = MetaStoreUtils.getColumnNamesForTable(table); List<String> partNames = rawStore.listPartitionNames(catName, dbName, tblName, (short) -1); // Get partition column stats for this table Deadline.startTimer("getPartitionColumnStatistics"); List<ColumnStatistics> partitionColStats = rawStore.getPartitionColumnStatistics(catName, dbName, tblName, partNames, colNames); Deadline.stopTimer(); sharedCache.refreshPartitionColStatsInCache(catName, dbName, tblName, partitionColStats); List<Partition> parts = rawStore.getPartitionsByNames(catName, dbName, tblName, partNames); // Also save partitions for consistency as they have the stats state. for (Partition part : parts) { sharedCache.alterPartitionInCache(catName, dbName, tblName, part.getValues(), part); } committed = rawStore.commitTransaction(); } catch (MetaException | NoSuchObjectException e) { LOG.info("Updating CachedStore: unable to read partitions of table: " + tblName, e); } finally { if (!committed) { sharedCache.removeAllPartitionColStatsFromCache(catName, dbName, tblName); rawStore.rollbackTransaction(); } } }
tbl = ms.getTable(part.getCatName(), part.getDbName(), part.getTableName(), null); if (tbl == null) { throw new InvalidObjectException(
parameters = getMS().updateTableColumnStatistics(colStats, validWriteIds, writeId); if (parameters != null) { Table tableObj = getMS().getTable(colStats.getStatsDesc().getCatName(), colStats.getStatsDesc().getDbName(), colStats.getStatsDesc().getTableName(), validWriteIds);