public void dropHiveTable(String table) throws LensException { try { getClient().dropTable(table); } catch (HiveException e) { throw new LensException("Couldn't drop hive table: " + table, e); } allHiveTables.remove(table.trim().toLowerCase()); }
private Table refreshTable(String tableName) throws LensException { Table tbl; try { tableName = tableName.trim().toLowerCase(); tbl = getClient().getTable(tableName); allHiveTables.put(tableName, tbl); } catch (HiveException e) { throw new LensException("Could not get table: " + tableName, e); } return tbl; }
private Table refreshTable(String tableName) throws LensException { Table tbl; try { tableName = tableName.trim().toLowerCase(); tbl = getClient().getTable(tableName); allHiveTables.put(tableName, tbl); } catch (HiveException e) { throw new LensException("Could not get table: " + tableName, e); } return tbl; }
public void dropHiveTable(String table) throws LensException { try { getClient().dropTable(table); } catch (HiveException e) { throw new LensException("Couldn't drop hive table: " + table, e); } allHiveTables.remove(table.trim().toLowerCase()); }
public void updatePartitions(String factOrDimtableName, String storageName, Map<UpdatePeriod, List<Partition>> partitions) throws HiveException, InvalidOperationException, LensException { for (Map.Entry entry : partitions.entrySet()) { List<Partition> partitionsToAlter = Lists.newArrayList(); partitionsToAlter.addAll((List<Partition>) entry.getValue()); String storageTableName = getStorageTableName(factOrDimtableName, storageName, (UpdatePeriod) entry.getKey()); partitionsToAlter.addAll( getAllLatestPartsEquivalentTo(factOrDimtableName, storageTableName, (List<Partition>) entry.getValue())); getStorage(storageName).updatePartitions(storageTableName, getClient(), factOrDimtableName, partitionsToAlter); } }
public boolean tableExists(String tblName) throws HiveException { try { return (getClient().getTable(tblName.toLowerCase(), false) != null); } catch (HiveException e) { throw new HiveException("Could not check whether table exists", e); } }
public void updatePartitions(String factOrDimtableName, String storageName, Map<UpdatePeriod, List<Partition>> partitions) throws HiveException, InvalidOperationException, LensException { for (Map.Entry entry : partitions.entrySet()) { List<Partition> partitionsToAlter = Lists.newArrayList(); partitionsToAlter.addAll((List<Partition>) entry.getValue()); String storageTableName = getStorageTableName(factOrDimtableName, storageName, (UpdatePeriod) entry.getKey()); partitionsToAlter.addAll( getAllLatestPartsEquivalentTo(factOrDimtableName, storageTableName, (List<Partition>) entry.getValue())); getStorage(storageName).updatePartitions(storageTableName, getClient(), factOrDimtableName, partitionsToAlter); } }
private Collection<String> getAllHiveTableNames() throws HiveException, LensException { if (!allTablesPopulated) { List<String> allTables = getClient().getAllTables(); for (String tblName : allTables) { // getTable call here would add the table to allHiveTables getTable(tblName); } allTablesPopulated = enableCaching; return allTables; } else { return allHiveTables.keySet(); } }
private Collection<String> getAllHiveTableNames() throws HiveException, LensException { if (!allTablesPopulated) { List<String> allTables = getClient().getAllTables(); for (String tblName : allTables) { // getTable call here would add the table to allHiveTables getTable(tblName); } allTablesPopulated = enableCaching; return allTables; } else { return allHiveTables.keySet(); } }
public boolean tableExists(String tblName) throws HiveException { try { return (getClient().getTable(tblName.toLowerCase(), false) != null); } catch (HiveException e) { throw new HiveException("Could not check whether table exists", e); } }
public List<Partition> getAllParts(String storageTableName) throws HiveException, LensException { return getClient().getPartitions(getHiveTable(storageTableName)); }
public List<Partition> getPartitionsByFilter(String storageTableName, String filter) throws HiveException { try { return getClient().getPartitionsByFilter(getTable(storageTableName), filter); } catch (Exception e) { throw new HiveException(e); } }
public void alterHiveTable(String table, Table hiveTable) throws HiveException, LensException { try { getClient().alterTable(table, hiveTable, null); } catch (InvalidOperationException e) { throw new HiveException(e); } if (enableCaching) { // refresh the table in cache refreshTable(table); } }
public List<Partition> getPartitionsByFilter(String storageTableName, String filter) throws HiveException { try { return getClient().getPartitionsByFilter(getTable(storageTableName), filter); } catch (Exception e) { throw new HiveException(e); } }
public void alterHiveTable(String table, Table hiveTable) throws HiveException, LensException { try { getClient().alterTable(table, hiveTable, null); } catch (InvalidOperationException e) { throw new HiveException(e); } if (enableCaching) { // refresh the table in cache refreshTable(table); } }
private boolean partitionExists(String storageTableName, Map<String, String> partSpec) throws LensException { try { Table storageTbl = getTable(storageTableName); Partition p = getClient().getPartition(storageTbl, partSpec, false); return (p != null && p.getTPartition() != null); } catch (HiveException e) { throw new LensException("Could not check whether table exists", e); } }
private boolean partitionExists(String storageTableName, Map<String, String> partSpec) throws LensException { try { Table storageTbl = getTable(storageTableName); Partition p = getClient().getPartition(storageTbl, partSpec, false); return (p != null && p.getTPartition() != null); } catch (HiveException e) { throw new LensException("Could not check whether table exists", e); } }
public boolean partitionExistsByFilter(String storageTableName, String filter) throws LensException { int parts; Table tbl; try { tbl = getTable(storageTableName); } catch (Exception e) { return false; } try { parts = getClient().getNumPartitionsByFilter(tbl, filter); } catch (Exception e) { throw new LensException("Could not find partitions for given filter", e); } return parts > 0; }
private Table createCubeHiveTable(AbstractCubeTable table) throws LensException { try { Table tbl = getClient().newTable(table.getName().toLowerCase()); tbl.setTableType(TableType.MANAGED_TABLE); tbl.getTTable().getSd().setCols(table.getColumns()); tbl.getTTable().getParameters().putAll(table.getProperties()); getClient().createTable(tbl); // do get to update cache getTable(tbl.getTableName()); return tbl; } catch (Exception e) { throw new LensException("Exception creating table", e); } }
public boolean partitionExistsByFilter(String storageTableName, String filter) throws LensException { int parts; Table tbl; try { tbl = getTable(storageTableName); } catch (Exception e) { return false; } try { parts = getClient().getNumPartitionsByFilter(tbl, filter); } catch (Exception e) { throw new LensException("Could not find partitions for given filter", e); } return parts > 0; }