15 package com.cloudera.impala.catalog;
17 import java.util.EnumSet;
19 import org.apache.hadoop.hive.metastore.TableType;
20 import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
21 import org.apache.log4j.Logger;
30 private static final Logger
LOG = Logger.getLogger(TableLoader.class);
34 TableType.EXTERNAL_TABLE, TableType.MANAGED_TABLE, TableType.VIRTUAL_VIEW);
59 String fullTblName = db.getName() +
"." + tblName;
60 LOG.info(
"Loading metadata for: " + fullTblName);
65 msClient = catalog_.getMetaStoreClient();
66 org.apache.hadoop.hive.metastore.api.Table msTbl = null;
69 msTbl = msClient.getHiveClient().getTable(db.
getName(), tblName);
72 TableType tableType = TableType.valueOf(msTbl.getTableType());
75 "Unsupported table type '%s' for: %s", tableType, fullTblName));
79 table = Table.fromMetastoreTable(catalog_.getNextTableId(), db, msTbl);
82 "Unrecognized table type for table: " + fullTblName);
84 table.load(cachedValue, msClient.getHiveClient(), msTbl);
87 table = IncompleteTable.createFailedMetadataLoadTable(
88 TableId.createInvalidId(), db, tblName, e);
89 }
catch (NoSuchObjectException e) {
91 "Table " + fullTblName +
" no longer exists in the Hive MetaStore. " +
92 "Run 'invalidate metadata " + fullTblName +
"' to update the Impala " +
94 table = IncompleteTable.createFailedMetadataLoadTable(
95 TableId.createInvalidId(), db, tblName, tableDoesNotExist);
96 }
catch (Exception e) {
97 table = IncompleteTable.createFailedMetadataLoadTable(
99 "Failed to load metadata for table: " + fullTblName +
". Running " +
100 "'invalidate metadata " + fullTblName +
"' may resolve this problem.", e));
102 if (msClient != null) msClient.release();
static EnumSet< TableType > SUPPORTED_TABLE_TYPES
Table load(Db db, String tblName, Table cachedValue)
TableLoader(CatalogServiceCatalog catalog)
final CatalogServiceCatalog catalog_
static final Object metastoreAccessLock_