use of io.cdap.cdap.api.data.schema.Schema in project hydrator-plugins by cdapio.
the class CountIfTest method testCondition.
@Test
public void testCondition() {
String condition = "x > 1";
Schema schema = Schema.recordOf("test", Schema.Field.of("x", Schema.nullableOf(Schema.of(Schema.Type.INT))));
test(new CountIf("x", JexlCondition.of(condition)), schema, "x", 2L, Arrays.asList(1, 2, null, null, 3), new CountIf("x", JexlCondition.of(condition)));
test(new CountIf("y", JexlCondition.of(condition)), schema, "x", 0L, Arrays.asList(1, 2, null, null, 3), new CountIf("y", JexlCondition.of(condition)));
}
use of io.cdap.cdap.api.data.schema.Schema in project hydrator-plugins by cdapio.
the class CountTest method testCount.
@Test
public void testCount() {
Schema schema = Schema.recordOf("test", Schema.Field.of("x", Schema.nullableOf(Schema.of(Schema.Type.INT))));
test(new Count("x"), schema, "x", 3L, Arrays.asList(1, 2, null, null, 3), new Count("x"));
test(new Count("y"), schema, "x", 0L, Arrays.asList(1, 2, null, null, 3), new Count("y"));
}
use of io.cdap.cdap.api.data.schema.Schema in project hydrator-plugins by cdapio.
the class RowDenormalizerConfigTest method testDenormalizerWithWrongKeyField.
@Test(expected = ValidationException.class)
public void testDenormalizerWithWrongKeyField() throws Exception {
Schema inputSchema = Schema.recordOf("record", Schema.Field.of("KeyField", Schema.nullableOf(Schema.of(Schema.Type.STRING))), Schema.Field.of("NameField", Schema.nullableOf(Schema.of(Schema.Type.STRING))), Schema.Field.of("ValueField", Schema.nullableOf(Schema.of(Schema.Type.STRING))));
MockPipelineConfigurer configurer = new MockPipelineConfigurer(inputSchema, Collections.emptyMap());
RowDenormalizerConfig config = new RowDenormalizerConfig("WrongKeyField", "NameField", "ValueField", "Firstname," + "Lastname,Address", "Lastname:lname,Address:addr");
RowDenormalizerAggregator aggregator = new RowDenormalizerAggregator(config);
aggregator.configurePipeline(configurer);
configurer.getStageConfigurer().getFailureCollector().getOrThrowException();
}
use of io.cdap.cdap.api.data.schema.Schema in project hydrator-plugins by cdapio.
the class AvgIfTest method testFloatCondition.
@Test
public void testFloatCondition() {
String condition = "x>-100f";
Schema schema = Schema.recordOf("test", Schema.Field.of("x", Schema.of(Schema.Type.FLOAT)));
Avg avg = new AvgIf("x", Schema.of(Schema.Type.FLOAT), JexlCondition.of(condition));
Avg avg1 = new AvgIf("x", Schema.of(Schema.Type.FLOAT), JexlCondition.of(condition));
testFunction(avg, schema, avg1, 0d, 0);
testFunction(avg, schema, avg1, 21d / 6d, 1f, 2f, 3f, 4f, 5f, 6f, -101F);
testFunction(avg, schema, avg1, 93d / 4d, -10f, 0f, 3f, 100f, -101F);
testFunction(avg, schema, avg1, 0.111d / 4d, 0f, 0.1f, 0.01f, 0.001f, -101F);
}
use of io.cdap.cdap.api.data.schema.Schema in project hydrator-plugins by cdapio.
the class AvgIfTest method testIntCondition.
@Test
public void testIntCondition() {
String condition = "x>1";
Schema schema = Schema.recordOf("test", Schema.Field.of("x", Schema.of(Schema.Type.INT)));
AvgIf avg = new AvgIf("x", Schema.of(Schema.Type.INT), JexlCondition.of(condition));
AvgIf avg1 = new AvgIf("x", Schema.of(Schema.Type.INT), JexlCondition.of(condition));
testFunction(avg, schema, avg1, null, 0);
testFunction(avg, schema, avg1, 20d / 5d, 1, 2, 3, 4, 5, 6);
testFunction(avg, schema, avg1, 103d / 2d, -10, 0, 3, 100);
}
Aggregations