use of com.yahoo.bullet.parsing.Projection in project bullet-core by yahoo.
the class Querier method project.
private BulletRecord project(BulletRecord record) {
Projection projection = runningQuery.getQuery().getProjection();
BulletRecord projected = projection != null ? ProjectionOperations.project(record, projection) : record;
return addAdditionalFields(projected);
}
use of com.yahoo.bullet.parsing.Projection in project bullet-core by yahoo.
the class ProjectionOperationsTest method testUnsupportedProjection.
@Test
public void testUnsupportedProjection() {
Projection projection = makeProjection(ImmutablePair.of("list_field.1.foo", "bar"), ImmutablePair.of("field", "foo"));
BulletRecord record = RecordBox.get().addList("list_field", emptyMap(), singletonMap("foo", "bar")).add("field", "123").getRecord();
BulletRecord actual = ProjectionOperations.project(record, projection);
BulletRecord expected = RecordBox.get().add("foo", "123").getRecord();
Assert.assertEquals(actual, expected);
}
use of com.yahoo.bullet.parsing.Projection in project bullet-core by yahoo.
the class ProjectionOperationsTest method testMapList.
@Test
public void testMapList() {
Projection projection = makeProjection("list_field", "foo");
BulletRecord record = RecordBox.get().addList("list_field", emptyMap(), singletonMap("foo", "baz")).getRecord();
BulletRecord expected = RecordBox.get().addList("foo", emptyMap(), singletonMap("foo", "baz")).getRecord();
BulletRecord actual = ProjectionOperations.project(record, projection);
Assert.assertEquals(actual, expected);
}
use of com.yahoo.bullet.parsing.Projection in project bullet-core by yahoo.
the class ProjectionOperationsTest method testProjection.
@Test
public void testProjection() {
Projection projection = makeProjection("map_field.foo", "bar");
RecordBox box = RecordBox.get().addMap("map_field", Pair.of("foo", "baz"));
BulletRecord actual = ProjectionOperations.project(box.getRecord(), projection);
BulletRecord expected = RecordBox.get().add("bar", "baz").getRecord();
Assert.assertEquals(actual, expected);
}
use of com.yahoo.bullet.parsing.Projection in project bullet-core by yahoo.
the class ProjectionOperationsTest method testNullFieldName.
@Test
public void testNullFieldName() {
Projection projection = makeProjection(ImmutablePair.of(null, "test"), ImmutablePair.of("map_field.foo", "foo"));
BulletRecord record = RecordBox.get().add("field", "test").addMap("map_field", Pair.of("foo", "baz")).getRecord();
BulletRecord actual = ProjectionOperations.project(record, projection);
BulletRecord expected = RecordBox.get().add("foo", "baz").getRecord();
Assert.assertEquals(actual, expected);
}
Aggregations