Search in sources :

Example 1 with TableDeregisterStep

use of org.apache.gobblin.hive.TableDeregisterStep in project incubator-gobblin by apache.

the class HiveCopyEntityHelper method addTableDeregisterSteps.

@VisibleForTesting
protected int addTableDeregisterSteps(List<CopyEntity> copyEntities, String fileSet, int initialPriority, Table table) throws IOException {
    int stepPriority = initialPriority;
    Collection<Path> tablePaths = Lists.newArrayList();
    switch(this.getDeleteMethod()) {
        case RECURSIVE:
            tablePaths = Lists.newArrayList(table.getDataLocation());
            break;
        case INPUT_FORMAT:
            InputFormat<?, ?> inputFormat = HiveUtils.getInputFormat(table.getSd());
            HiveLocationDescriptor targetLocation = new HiveLocationDescriptor(table.getDataLocation(), inputFormat, this.getTargetFs(), this.getDataset().getProperties());
            tablePaths = targetLocation.getPaths().keySet();
            break;
        case NO_DELETE:
            tablePaths = Lists.newArrayList();
            break;
        default:
            tablePaths = Lists.newArrayList();
    }
    if (!tablePaths.isEmpty()) {
        DeleteFileCommitStep deletePaths = DeleteFileCommitStep.fromPaths(this.getTargetFs(), tablePaths, this.getDataset().getProperties(), table.getDataLocation());
        copyEntities.add(new PostPublishStep(fileSet, Maps.<String, String>newHashMap(), deletePaths, stepPriority++));
    }
    TableDeregisterStep deregister = new TableDeregisterStep(table.getTTable(), this.getTargetURI(), this.getHiveRegProps());
    copyEntities.add(new PostPublishStep(fileSet, Maps.<String, String>newHashMap(), deregister, stepPriority++));
    return stepPriority;
}
Also used : Path(org.apache.hadoop.fs.Path) PostPublishStep(org.apache.gobblin.data.management.copy.entities.PostPublishStep) DeleteFileCommitStep(org.apache.gobblin.util.commit.DeleteFileCommitStep) ToString(lombok.ToString) TableDeregisterStep(org.apache.gobblin.hive.TableDeregisterStep) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ToString (lombok.ToString)1 PostPublishStep (org.apache.gobblin.data.management.copy.entities.PostPublishStep)1 TableDeregisterStep (org.apache.gobblin.hive.TableDeregisterStep)1 DeleteFileCommitStep (org.apache.gobblin.util.commit.DeleteFileCommitStep)1 Path (org.apache.hadoop.fs.Path)1