Search in sources :

Example 1 with HBaseSink

use of io.cdap.plugin.sink.HBaseSink in project hydrator-plugins by cdapio.

the class HBaseSinkTest method testTableSinkWithComplexType.

@Test
public void testTableSinkWithComplexType() {
    Schema outputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("complex", Schema.mapOf(Schema.of(Schema.Type.STRING), Schema.of(Schema.Type.STRING))));
    Schema inputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("complex", Schema.mapOf(Schema.of(Schema.Type.STRING), Schema.of(Schema.Type.STRING))));
    HBaseSink.HBaseSinkConfig tableSinkConfig = new HBaseSink.HBaseSinkConfig("hbaseSink", "rowkey", outputSchema.toString());
    HBaseSink tableSink = new HBaseSink(tableSinkConfig);
    MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
    tableSink.configurePipeline(mockPipelineConfigurer);
    FailureCollector collector = mockPipelineConfigurer.getStageConfigurer().getFailureCollector();
    Assert.assertEquals(1, collector.getValidationFailures().size());
    List<ValidationFailure.Cause> causes = collector.getValidationFailures().get(0).getCauses();
    Assert.assertEquals(2, causes.size());
}
Also used : HBaseSink(io.cdap.plugin.sink.HBaseSink) MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Example 2 with HBaseSink

use of io.cdap.plugin.sink.HBaseSink in project hydrator-plugins by cdapio.

the class HBaseSinkTest method testTableSink.

@Test
public void testTableSink() {
    Schema outputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("count", Schema.of(Schema.Type.INT)));
    Schema inputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("count", Schema.of(Schema.Type.INT)));
    HBaseSink.HBaseSinkConfig tableSinkConfig = new HBaseSink.HBaseSinkConfig("hbaseSink", "rowkey", outputSchema.toString());
    HBaseSink tableSink = new HBaseSink(tableSinkConfig);
    MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
    tableSink.configurePipeline(mockPipelineConfigurer);
    Assert.assertEquals(outputSchema, mockPipelineConfigurer.getOutputSchema());
}
Also used : HBaseSink(io.cdap.plugin.sink.HBaseSink) MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) Test(org.junit.Test)

Example 3 with HBaseSink

use of io.cdap.plugin.sink.HBaseSink in project hydrator-plugins by cdapio.

the class HBaseSinkTest method testTableSinkWithMissingOutputSchema.

@Test
public void testTableSinkWithMissingOutputSchema() {
    HBaseSink.HBaseSinkConfig tableSinkConfig = new HBaseSink.HBaseSinkConfig("hbaseSink", "rowkey", null);
    HBaseSink tableSink = new HBaseSink(tableSinkConfig);
    MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(null);
    tableSink.configurePipeline(mockPipelineConfigurer);
}
Also used : HBaseSink(io.cdap.plugin.sink.HBaseSink) MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Test(org.junit.Test)

Example 4 with HBaseSink

use of io.cdap.plugin.sink.HBaseSink in project hydrator-plugins by cdapio.

the class HBaseSinkTest method testTableSinkWithOutputSchemaExtraField.

@Test
public void testTableSinkWithOutputSchemaExtraField() {
    Schema outputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)), Schema.Field.of("points", Schema.of(Schema.Type.DOUBLE)));
    Schema inputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)));
    HBaseSink.HBaseSinkConfig tableSinkConfig = new HBaseSink.HBaseSinkConfig("hbaseSink", "rowkey", outputSchema.toString());
    HBaseSink tableSink = new HBaseSink(tableSinkConfig);
    MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
    tableSink.configurePipeline(mockPipelineConfigurer);
    FailureCollector collector = mockPipelineConfigurer.getStageConfigurer().getFailureCollector();
    Assert.assertEquals(1, collector.getValidationFailures().size());
}
Also used : HBaseSink(io.cdap.plugin.sink.HBaseSink) MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Example 5 with HBaseSink

use of io.cdap.plugin.sink.HBaseSink in project hydrator-plugins by cdapio.

the class HBaseSinkTest method testTableSinkWithMissingRowKeyField.

@Test
public void testTableSinkWithMissingRowKeyField() {
    Schema outputSchema = Schema.recordOf("purchase", Schema.Field.of("rowkey", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)));
    Schema inputSchema = Schema.recordOf("purchase", Schema.Field.of("userid", Schema.of(Schema.Type.STRING)), Schema.Field.of("user", Schema.of(Schema.Type.STRING)));
    HBaseSink.HBaseSinkConfig tableSinkConfig = new HBaseSink.HBaseSinkConfig("hbaseSink", "rowkey", outputSchema.toString());
    HBaseSink tableSink = new HBaseSink(tableSinkConfig);
    MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(inputSchema);
    tableSink.configurePipeline(mockPipelineConfigurer);
    FailureCollector collector = mockPipelineConfigurer.getStageConfigurer().getFailureCollector();
    Assert.assertEquals(1, collector.getValidationFailures().size());
}
Also used : HBaseSink(io.cdap.plugin.sink.HBaseSink) MockPipelineConfigurer(io.cdap.cdap.etl.mock.common.MockPipelineConfigurer) Schema(io.cdap.cdap.api.data.schema.Schema) FailureCollector(io.cdap.cdap.etl.api.FailureCollector) Test(org.junit.Test)

Aggregations

MockPipelineConfigurer (io.cdap.cdap.etl.mock.common.MockPipelineConfigurer)7 HBaseSink (io.cdap.plugin.sink.HBaseSink)7 Test (org.junit.Test)7 Schema (io.cdap.cdap.api.data.schema.Schema)6 FailureCollector (io.cdap.cdap.etl.api.FailureCollector)4