private HiveDataset getHiveDataset(String tableString, FileSystem fs, State state) throws IOException { try { HiveMetastoreClientPool pool = HiveMetastoreClientPool.get(state.getProperties(), Optional.fromNullable(state.getProp(HIVE_METASTORE_URI_KEY))); List<String> tokens = Splitter.on(".").splitToList(tableString); DbAndTable sourceDbAndTable = new DbAndTable(tokens.get(0), tokens.get(1)); try (AutoReturnableObject<IMetaStoreClient> client = pool.getClient()) { Table sourceTable = new Table(client.get().getTable(sourceDbAndTable.getDb(), sourceDbAndTable.getTable())); return new HiveDataset(fs, pool, sourceTable, ConfigUtils.propertiesToConfig(state.getProperties())); } } catch (TException exc) { throw new RuntimeException(exc); } }
private static FileReference fileReference(String key, String reference) { if (reference.startsWith("s3:")) { // File on S3 AmazonS3URI uri; try { uri = new AmazonS3URI(reference); Preconditions.checkArgument(uri.getKey() != null & !uri.getKey().endsWith("/"), "must be a file"); } catch (IllegalArgumentException e) { throw new ConfigException("Invalid " + key + ": '" + reference + "'", e); } return ImmutableFileReference.builder() .reference(reference) .filename(Iterables.getLast(Splitter.on('/').split(reference), "")) .type(S3) .build(); } else { // Local file return ImmutableFileReference.builder() .reference(reference) .filename(Paths.get(reference).getFileName().toString()) .type(LOCAL) .build(); } }
private HiveDataset getHiveDataset(String tableString, FileSystem fs, State state) throws IOException { try { HiveMetastoreClientPool pool = HiveMetastoreClientPool.get(state.getProperties(), Optional.fromNullable(state.getProp(HIVE_METASTORE_URI_KEY))); List<String> tokens = Splitter.on(".").splitToList(tableString); DbAndTable sourceDbAndTable = new DbAndTable(tokens.get(0), tokens.get(1)); try (AutoReturnableObject<IMetaStoreClient> client = pool.getClient()) { Table sourceTable = new Table(client.get().getTable(sourceDbAndTable.getDb(), sourceDbAndTable.getTable())); return new HiveDataset(fs, pool, sourceTable, ConfigUtils.propertiesToConfig(state.getProperties())); } } catch (TException exc) { throw new RuntimeException(exc); } }