use of org.apache.hadoop.hive.metastore.model.MMVSource in project hive by apache.
the class ObjectStore method convertToMCreationMetadata.
private MCreationMetadata convertToMCreationMetadata(CreationMetadata m) {
if (m == null) {
return null;
}
assert !m.isSetMaterializationTime();
Set<MMVSource> tablesUsed = new HashSet<>();
for (SourceTable sourceTable : m.getSourceTables()) {
Table table = sourceTable.getTable();
MTable mtbl = getMTable(m.getCatName(), table.getDbName(), table.getTableName(), false).mtbl;
MMVSource source = new MMVSource();
source.setTable(mtbl);
source.setInsertedCount(sourceTable.getInsertedCount());
source.setUpdatedCount(sourceTable.getUpdatedCount());
source.setDeletedCount(sourceTable.getDeletedCount());
tablesUsed.add(source);
}
return new MCreationMetadata(normalizeIdentifier(m.getCatName()), normalizeIdentifier(m.getDbName()), normalizeIdentifier(m.getTblName()), tablesUsed, m.getValidTxnList(), System.currentTimeMillis());
}
use of org.apache.hadoop.hive.metastore.model.MMVSource in project hive by apache.
the class ObjectStore method convertToCreationMetadata.
private CreationMetadata convertToCreationMetadata(MCreationMetadata s) throws MetaException {
if (s == null) {
return null;
}
Set<String> tablesUsed = new HashSet<>();
List<SourceTable> sourceTables = new ArrayList<>(s.getTables().size());
for (MMVSource mtbl : s.getTables()) {
tablesUsed.add(Warehouse.getQualifiedName(mtbl.getTable().getDatabase().getName(), mtbl.getTable().getTableName()));
sourceTables.add(convertToSourceTable(mtbl, s.getCatalogName()));
}
CreationMetadata r = new CreationMetadata(s.getCatalogName(), s.getDbName(), s.getTblName(), tablesUsed);
r.setMaterializationTime(s.getMaterializationTime());
if (s.getTxnList() != null) {
r.setValidTxnList(s.getTxnList());
}
r.setSourceTables(sourceTables);
return r;
}
use of org.apache.hadoop.hive.metastore.model.MMVSource in project hive by apache.
the class ObjectStore method isPartOfMaterializedView.
@Override
public List<String> isPartOfMaterializedView(String catName, String dbName, String tblName) {
boolean committed = false;
Query query = null;
List<String> mViewList = new ArrayList<>();
try {
openTransaction();
query = pm.newQuery("select from org.apache.hadoop.hive.metastore.model.MCreationMetadata");
List<MCreationMetadata> creationMetadata = (List<MCreationMetadata>) query.execute();
Iterator<MCreationMetadata> iter = creationMetadata.iterator();
while (iter.hasNext()) {
MCreationMetadata p = iter.next();
Set<MMVSource> tables = p.getTables();
for (MMVSource sourceTable : tables) {
MTable table = sourceTable.getTable();
if (dbName.equals(table.getDatabase().getName()) && tblName.equals(table.getTableName())) {
LOG.info("Cannot drop table " + table.getTableName() + " as it is being used by MView " + p.getTblName());
mViewList.add(p.getDbName() + "." + p.getTblName());
}
}
}
committed = commitTransaction();
} finally {
rollbackAndCleanup(committed, query);
}
return mViewList;
}
Aggregations