Search in sources :

Example 1 with HiveTablePersistentOutput

use of com.airbnb.airpal.api.output.HiveTablePersistentOutput in project airpal by airbnb.

the class ExecutionClient method jobFinished.

protected void jobFinished(Job job) {
    job.setQueryFinished(new DateTime());
    activeJobsStore.jobFinished(job);
    historyStore.addRun(job);
    for (Table t : job.getTablesUsed()) {
        usageStore.markUsage(t);
    }
    if (job.getOutput() instanceof HiveTablePersistentOutput && job.getOutput().getLocation() != null) {
        String[] parts = job.getOutput().getLocation().toString().split("\\.");
        if (parts.length == 2) {
            Map<String, List<String>> cache = schemaCache.getSchemaMap("hive");
            List<String> tables = cache.get(parts[0]);
            tables.add(parts[1]);
        }
    }
    eventBus.post(new JobFinishedEvent(job));
    executionMap.remove(job.getUuid());
}
Also used : Table(com.airbnb.airpal.presto.Table) HiveTablePersistentOutput(com.airbnb.airpal.api.output.HiveTablePersistentOutput) JobFinishedEvent(com.airbnb.airpal.api.event.JobFinishedEvent) List(java.util.List) DateTime(org.joda.time.DateTime)

Example 2 with HiveTablePersistentOutput

use of com.airbnb.airpal.api.output.HiveTablePersistentOutput in project airpal by airbnb.

the class OutputBuilderFactory method forJob.

public JobOutputBuilder forJob(Job job) throws IOException, InvalidQueryException {
    PersistentJobOutput output = job.getOutput();
    switch(output.getType()) {
        case "csv":
            return new CsvOutputBuilder(true, job.getUuid(), maxFileSizeBytes, isCompressedOutput);
        case "hive":
            HiveTablePersistentOutput hiveOutput = (HiveTablePersistentOutput) output;
            URI location = output.getLocation();
            if (location == null) {
                throw new InvalidQueryException(format("Invalid table name '%s'", hiveOutput.getTmpTableName()));
            }
            return new HiveTableOutputBuilder(hiveOutput.getDestinationSchema(), hiveOutput.getTmpTableName());
        default:
            throw new IllegalArgumentException(format("OutputBuilder for type %s not found", output.getType()));
    }
}
Also used : HiveTablePersistentOutput(com.airbnb.airpal.api.output.HiveTablePersistentOutput) PersistentJobOutput(com.airbnb.airpal.api.output.PersistentJobOutput) URI(java.net.URI) InvalidQueryException(com.airbnb.airpal.api.output.InvalidQueryException)

Aggregations

HiveTablePersistentOutput (com.airbnb.airpal.api.output.HiveTablePersistentOutput)2 JobFinishedEvent (com.airbnb.airpal.api.event.JobFinishedEvent)1 InvalidQueryException (com.airbnb.airpal.api.output.InvalidQueryException)1 PersistentJobOutput (com.airbnb.airpal.api.output.PersistentJobOutput)1 Table (com.airbnb.airpal.presto.Table)1 URI (java.net.URI)1 List (java.util.List)1 DateTime (org.joda.time.DateTime)1