/** * Drop a storage from dimension * * @param dimTblName dim table name * @param storage storage * @throws HiveException */ public void dropStorageFromDim(String dimTblName, String storage) throws HiveException, LensException { dropStorageFromDim(dimTblName, storage, true); }
/** * Drop a storage from dimension * * @param dimTblName dim table name * @param storage storage * @throws HiveException */ public void dropStorageFromDim(String dimTblName, String storage) throws HiveException, LensException { dropStorageFromDim(dimTblName, storage, true); }
/** * Drop the dimension table * * @param dimTblName dim table name * @param cascade If true, will drop all the dimension storages * @throws HiveException */ public void dropDimensionTable(String dimTblName, boolean cascade) throws LensException { getTableWithTypeFailFast(dimTblName, CubeTableType.DIM_TABLE); CubeDimensionTable dim = getDimensionTable(dimTblName); if (cascade) { for (String storage : dim.getStorages()) { dropStorageFromDim(dimTblName, storage, false); } } dropHiveTable(dimTblName); allDimTables.remove(dimTblName.trim().toLowerCase()); }
@Override public void dropAllStoragesOfDimTable(LensSessionHandle sessionid, String dimTblName) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ CubeMetastoreClient msClient = getClient(sessionid); CubeDimensionTable tab = msClient.getDimensionTable(dimTblName); int total = tab.getStorages().size(); int i = 0; List<String> storageNames = new ArrayList<>(tab.getStorages()); for (String s : storageNames) { msClient.dropStorageFromDim(dimTblName, s); log.info("Dropped storage " + s + " from dimension table " + dimTblName + " [" + ++i + "/" + total + "]"); } log.info("Dropped " + total + " storages from dimension table " + dimTblName); } catch (HiveException exc) { throw new LensException(exc); } }
/** * Drop the dimension table * * @param dimTblName dim table name * @param cascade If true, will drop all the dimension storages * @throws HiveException */ public void dropDimensionTable(String dimTblName, boolean cascade) throws LensException { checkIfAuthorized(); getTableWithTypeFailFast(dimTblName, CubeTableType.DIM_TABLE); CubeDimensionTable dim = getDimensionTable(dimTblName); if (cascade) { for (String storage : dim.getStorages()) { dropStorageFromDim(dimTblName, storage, false); } } dropHiveTable(dimTblName); allDimTables.remove(dimTblName.trim().toLowerCase()); }
@Override public void dropStorageOfDimTable(LensSessionHandle sessionid, String dimTblName, String storage) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ CubeMetastoreClient msClient = getClient(sessionid); CubeDimensionTable tab = msClient.getDimensionTable(dimTblName); if (!tab.getStorages().contains(storage)) { throw new NotFoundException("Storage " + storage + " not found for dimension " + dimTblName); } msClient.dropStorageFromDim(dimTblName, storage); log.info("Dropped storage " + storage + " from dimension table " + dimTblName); } catch (HiveException exc) { throw new LensException(exc); } }
client.dropStorageFromDim(cubeDim.getName(), c1); assertFalse(client.dimTableLatestPartitionExists(storageTableName));
assertFalse(altered3.hasStorageSnapshots("C2")); assertTrue(altered3.hasStorageSnapshots("C3")); client.dropStorageFromDim(dimTblName, "C1"); assertFalse(client.tableExists(getFactOrDimtableStorageTableName(dimTblName, c1))); client.dropDimensionTable(dimTblName, true);