Search in sources :

Example 1 with StageableTableMetadata

use of org.apache.gobblin.data.management.conversion.hive.entities.StageableTableMetadata in project incubator-gobblin by apache.

the class HiveMaterializerSource method getWorkunits.

@Override
public List<WorkUnit> getWorkunits(SourceState state) {
    try {
        FileSystem fs = HadoopUtils.getSourceFileSystem(state);
        Config config = ConfigUtils.propertiesToConfig(state.getProperties());
        if (state.contains(COPY_TABLE_KEY)) {
            HiveDataset dataset = getHiveDataset(state.getProp(COPY_TABLE_KEY), fs, state);
            WorkUnit workUnit = HiveMaterializer.tableCopyWorkUnit(dataset, new StageableTableMetadata(config.getConfig(HIVE_MATERIALIZER_SOURCE_PREFIX), dataset.getTable()), null);
            HiveTask.disableHiveWatermarker(workUnit);
            return Lists.newArrayList(workUnit);
        } else if (state.contains(MATERIALIZE_VIEW)) {
            HiveDataset dataset = getHiveDataset(state.getProp(MATERIALIZE_VIEW), fs, state);
            WorkUnit workUnit = HiveMaterializer.viewMaterializationWorkUnit(dataset, getOutputStorageFormat(state), new StageableTableMetadata(config.getConfig(HIVE_MATERIALIZER_SOURCE_PREFIX), dataset.getTable()), null);
            HiveTask.disableHiveWatermarker(workUnit);
            return Lists.newArrayList(workUnit);
        } else if (state.contains(MATERIALIZE_QUERY)) {
            String query = state.getProp(MATERIALIZE_QUERY);
            WorkUnit workUnit = HiveMaterializer.queryResultMaterializationWorkUnit(query, getOutputStorageFormat(state), new StageableTableMetadata(config.getConfig(HIVE_MATERIALIZER_SOURCE_PREFIX), null));
            HiveTask.disableHiveWatermarker(workUnit);
            return Lists.newArrayList(workUnit);
        }
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
    throw new RuntimeException(String.format("Must specify either %s, %s, or %s.", COPY_TABLE_KEY, MATERIALIZE_QUERY, MATERIALIZE_VIEW));
}
Also used : Config(com.typesafe.config.Config) FileSystem(org.apache.hadoop.fs.FileSystem) HiveDataset(org.apache.gobblin.data.management.copy.hive.HiveDataset) WorkUnit(org.apache.gobblin.source.workunit.WorkUnit) IOException(java.io.IOException) StageableTableMetadata(org.apache.gobblin.data.management.conversion.hive.entities.StageableTableMetadata)

Aggregations

Config (com.typesafe.config.Config)1 IOException (java.io.IOException)1 StageableTableMetadata (org.apache.gobblin.data.management.conversion.hive.entities.StageableTableMetadata)1 HiveDataset (org.apache.gobblin.data.management.copy.hive.HiveDataset)1 WorkUnit (org.apache.gobblin.source.workunit.WorkUnit)1 FileSystem (org.apache.hadoop.fs.FileSystem)1