Search in sources :

Example 1 with StageConfigurer

use of io.cdap.cdap.etl.api.StageConfigurer in project cdap by caskdata.

the class FieldsPrefixTransform method configurePipeline.

@Override
public void configurePipeline(PipelineConfigurer pipelineConfigurer) {
    StageConfigurer stageConfigurer = pipelineConfigurer.getStageConfigurer();
    try {
        Schema outSchema = config.getOutputSchema(Schema.parseJson(config.schemaStr));
        stageConfigurer.setOutputSchema(outSchema);
    } catch (Exception e) {
        throw new IllegalArgumentException("Invalid output schema: " + e.getMessage(), e);
    }
}
Also used : StageConfigurer(io.cdap.cdap.etl.api.StageConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema)

Example 2 with StageConfigurer

use of io.cdap.cdap.etl.api.StageConfigurer in project cdap by caskdata.

the class IntValueFilterTransform method configurePipeline.

@Override
public void configurePipeline(PipelineConfigurer pipelineConfigurer) {
    StageConfigurer stageConfigurer = pipelineConfigurer.getStageConfigurer();
    stageConfigurer.setOutputSchema(stageConfigurer.getInputSchema());
}
Also used : StageConfigurer(io.cdap.cdap.etl.api.StageConfigurer)

Example 3 with StageConfigurer

use of io.cdap.cdap.etl.api.StageConfigurer in project cdap by caskdata.

the class DropNullTransform method configurePipeline.

@Override
public void configurePipeline(PipelineConfigurer pipelineConfigurer) {
    StageConfigurer stageConfigurer = pipelineConfigurer.getStageConfigurer();
    Schema inputSchema = stageConfigurer.getInputSchema();
    if (inputSchema != null) {
        stageConfigurer.setOutputSchema(getOutputSchema(inputSchema));
    }
}
Also used : StageConfigurer(io.cdap.cdap.etl.api.StageConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema)

Example 4 with StageConfigurer

use of io.cdap.cdap.etl.api.StageConfigurer in project cdap by caskdata.

the class IdentityTransform method configurePipeline.

@Override
public void configurePipeline(PipelineConfigurer pipelineConfigurer) {
    StageConfigurer stageConfigurer = pipelineConfigurer.getStageConfigurer();
    stageConfigurer.setOutputSchema(stageConfigurer.getInputSchema());
}
Also used : StageConfigurer(io.cdap.cdap.etl.api.StageConfigurer)

Example 5 with StageConfigurer

use of io.cdap.cdap.etl.api.StageConfigurer in project cdap by caskdata.

the class StringValueFilterTransform method configurePipeline.

@Override
public void configurePipeline(PipelineConfigurer pipelineConfigurer) {
    StageConfigurer stageConfigurer = pipelineConfigurer.getStageConfigurer();
    Schema inputSchema = stageConfigurer.getInputSchema();
    FailureCollector collector = stageConfigurer.getFailureCollector();
    if (inputSchema != null && !config.containsMacro("field")) {
        Schema.Field field = inputSchema.getField(config.field);
        if (field == null) {
            collector.addFailure(String.format("'%s' is not a field in the input schema.", config.field), "Make sure field is present in the input schema.").withConfigProperty("field");
            collector.getOrThrowException();
        }
        Schema fieldSchema = field.getSchema();
        Schema.Type fieldType = fieldSchema.isNullable() ? fieldSchema.getNonNullable().getType() : fieldSchema.getType();
        if (fieldType != Schema.Type.STRING) {
            collector.addFailure(String.format("'%s' is of type '%s' instead of a string.", config.field, fieldType), "Make sure provided field is of type string.").withConfigProperty("field").withInputSchemaField(config.field);
        }
    }
    stageConfigurer.setOutputSchema(stageConfigurer.getInputSchema());
}
Also used : StageConfigurer(io.cdap.cdap.etl.api.StageConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) FailureCollector(io.cdap.cdap.etl.api.FailureCollector)

Aggregations

StageConfigurer (io.cdap.cdap.etl.api.StageConfigurer)18 Schema (io.cdap.cdap.api.data.schema.Schema)8 FailureCollector (io.cdap.cdap.etl.api.FailureCollector)1