@Override public void dropAllStoragesOfFact(LensSessionHandle sessionid, String factName) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ CubeMetastoreClient msClient = getClient(sessionid); CubeFactTable tab = msClient.getCubeFactTable(factName); int total = tab.getStorages().size(); int i = 0; List<String> storageNames = new ArrayList<>(tab.getStorages()); for (String s : storageNames) { msClient.dropStorageFromFact(factName, s); log.info("Dropped storage " + s + " from fact table " + factName + " [" + ++i + "/" + total + "]"); } log.info("Dropped " + total + " storages from fact table " + factName); } }
@Override public void dropStorageOfFact(LensSessionHandle sessionid, String fact, String storage) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ checkFactStorage(sessionid, fact, storage); getClient(sessionid).dropStorageFromFact(fact, storage); log.info("Dropped storage " + storage + " from fact " + fact); } catch (HiveException exc) { throw new LensException(exc); } }
/** * Drop a fact with cascade flag * * @param factName fact name * @param cascade If true, will drop all the storages of the fact * @throws LensException */ public void dropFact(String factName, boolean cascade) throws LensException { getTableWithTypeFailFast(factName, CubeTableType.FACT); FactTable fact = getFactTable(factName); if (cascade) { for (String storage : fact.getStorages()) { dropStorageFromFact(factName, storage, false); } } dropHiveTable(factName); allFactTables.remove(factName.trim().toLowerCase()); if (fact.isVirtualFact()) { String sourceFactTable = fact.getProperties().get(getSourceFactNameKey(fact.getName())); if (factToVirtualFactMapping.get(sourceFactTable) != null && factToVirtualFactMapping.get(sourceFactTable).contains(fact.getName())) { factToVirtualFactMapping.get(sourceFactTable).remove(fact.getName()); } } else { dropAllVirtualFactTables(factName); } }
/** * Drop a fact with cascade flag * * @param factName fact name * @param cascade If true, will drop all the storages of the fact * @throws LensException */ public void dropFact(String factName, boolean cascade) throws LensException { getTableWithTypeFailFast(factName, CubeTableType.FACT); FactTable fact = getFactTable(factName); checkIfAuthorized(); if (cascade) { for (String storage : fact.getStorages()) { dropStorageFromFact(factName, storage, false); } } dropHiveTable(factName); allFactTables.remove(factName.trim().toLowerCase()); if (fact.isVirtualFact()) { String sourceFactTable = fact.getProperties().get(getSourceFactNameKey(fact.getName())); if (factToVirtualFactMapping.get(sourceFactTable) != null && factToVirtualFactMapping.get(sourceFactTable).contains(fact.getName())) { factToVirtualFactMapping.get(sourceFactTable).remove(fact.getName()); } } else { dropAllVirtualFactTables(factName); } }
String storageTableName = getFactOrDimtableStorageTableName(factName, c3); assertTrue(client.tableExists(storageTableName)); client.dropStorageFromFact(factName, c2); storageTableName = getFactOrDimtableStorageTableName(factName, c2); assertFalse(client.tableExists(storageTableName));