@Override public List<String> generateQueries() { ensureParentOfStagingPathExists(); return Lists.newArrayList(HiveConverterUtils.generateStagingCTASStatement( new HiveDatasetFinder.DbAndTable(this.outputDatabaseName, this.stagingTableName), this.sourceQuery, this.storageFormat, this.stagingDataLocation)); }
/** * Generates a CTAS statement to dump the contents of a table / partition into a new table. * @param outputDbAndTable output db and table where contents should be written. * @param sourceEntity source table / partition. * @param partitionDMLInfo map of partition values. * @param storageFormat format of output table. * @param outputTableLocation location where files of output table should be written. */ public static String generateStagingCTASStatementFromSelectStar(HiveDatasetFinder.DbAndTable outputDbAndTable, HiveDatasetFinder.DbAndTable sourceEntity, Map<String, String> partitionDMLInfo, StorageFormat storageFormat, String outputTableLocation) { StringBuilder sourceQueryBuilder = new StringBuilder("SELECT * FROM `").append(sourceEntity.getDb()) .append("`.`").append(sourceEntity.getTable()).append("`"); if (partitionDMLInfo != null && !partitionDMLInfo.isEmpty()) { sourceQueryBuilder.append(" WHERE "); sourceQueryBuilder.append(partitionDMLInfo.entrySet().stream() .map(e -> "`" + e.getKey() + "`='" + e.getValue() + "'") .collect(joining(" AND "))); } return generateStagingCTASStatement(outputDbAndTable, sourceQueryBuilder.toString(), storageFormat, outputTableLocation); }
@Override public List<String> generateQueries() { ensureParentOfStagingPathExists(); return Lists.newArrayList(HiveConverterUtils.generateStagingCTASStatement( new HiveDatasetFinder.DbAndTable(this.outputDatabaseName, this.stagingTableName), this.sourceQuery, this.storageFormat, this.stagingDataLocation)); }
/** * Generates a CTAS statement to dump the contents of a table / partition into a new table. * @param outputDbAndTable output db and table where contents should be written. * @param sourceEntity source table / partition. * @param partitionDMLInfo map of partition values. * @param storageFormat format of output table. * @param outputTableLocation location where files of output table should be written. */ public static String generateStagingCTASStatementFromSelectStar(HiveDatasetFinder.DbAndTable outputDbAndTable, HiveDatasetFinder.DbAndTable sourceEntity, Map<String, String> partitionDMLInfo, StorageFormat storageFormat, String outputTableLocation) { StringBuilder sourceQueryBuilder = new StringBuilder("SELECT * FROM `").append(sourceEntity.getDb()) .append("`.`").append(sourceEntity.getTable()).append("`"); if (partitionDMLInfo != null && !partitionDMLInfo.isEmpty()) { sourceQueryBuilder.append(" WHERE "); sourceQueryBuilder.append(partitionDMLInfo.entrySet().stream() .map(e -> "`" + e.getKey() + "`='" + e.getValue() + "'") .collect(joining(" AND "))); } return generateStagingCTASStatement(outputDbAndTable, sourceQueryBuilder.toString(), storageFormat, outputTableLocation); }