Search in sources :

Example 21 with FieldExpression

use of com.yahoo.bullet.query.expressions.FieldExpression in project bullet-core by yahoo.

the class ExplodeFunctorTest method testApplyToNotList.

@Test
public void testApplyToNotList() {
    Explode explode = new Explode(new FieldExpression("mapA"), "foo", null, false);
    ExplodeFunctor functor = new ExplodeFunctor(explode);
    List<BulletRecord> records = functor.apply(record, provider);
    Assert.assertEquals(records.size(), 0);
}
Also used : Explode(com.yahoo.bullet.query.tablefunctions.Explode) BulletRecord(com.yahoo.bullet.record.BulletRecord) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Example 22 with FieldExpression

use of com.yahoo.bullet.query.expressions.FieldExpression in project bullet-core by yahoo.

the class ExplodeFunctorTest method testApplyToList.

@Test
public void testApplyToList() {
    Explode explode = new Explode(new FieldExpression("listA"), "foo", null, false);
    ExplodeFunctor functor = new ExplodeFunctor(explode);
    List<BulletRecord> records = functor.apply(record, provider);
    Assert.assertEquals(records.size(), 3);
    Assert.assertEquals(records.get(0).fieldCount(), 1);
    Assert.assertEquals(records.get(0).typedGet("foo").getValue(), 0);
    Assert.assertEquals(records.get(1).fieldCount(), 1);
    Assert.assertEquals(records.get(1).typedGet("foo").getValue(), 1);
    Assert.assertEquals(records.get(2).fieldCount(), 1);
    Assert.assertEquals(records.get(2).typedGet("foo").getValue(), 2);
}
Also used : Explode(com.yahoo.bullet.query.tablefunctions.Explode) BulletRecord(com.yahoo.bullet.record.BulletRecord) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Example 23 with FieldExpression

use of com.yahoo.bullet.query.expressions.FieldExpression in project bullet-core by yahoo.

the class ExplodeFunctorTest method testApplyToEmptyList.

@Test
public void testApplyToEmptyList() {
    Explode explode = new Explode(new FieldExpression("listB"), "foo", null, false);
    ExplodeFunctor functor = new ExplodeFunctor(explode);
    List<BulletRecord> records = functor.apply(record, provider);
    Assert.assertEquals(records.size(), 0);
}
Also used : Explode(com.yahoo.bullet.query.tablefunctions.Explode) BulletRecord(com.yahoo.bullet.record.BulletRecord) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Example 24 with FieldExpression

use of com.yahoo.bullet.query.expressions.FieldExpression in project bullet-core by yahoo.

the class ExplodeFunctorTest method testApplyToNotMap.

@Test
public void testApplyToNotMap() {
    Explode explode = new Explode(new FieldExpression("listA"), "foo", "bar", false);
    ExplodeFunctor functor = new ExplodeFunctor(explode);
    List<BulletRecord> records = functor.apply(record, provider);
    Assert.assertEquals(records.size(), 0);
}
Also used : Explode(com.yahoo.bullet.query.tablefunctions.Explode) BulletRecord(com.yahoo.bullet.record.BulletRecord) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Example 25 with FieldExpression

use of com.yahoo.bullet.query.expressions.FieldExpression in project bullet-core by yahoo.

the class ExplodeFunctorTest method testApplyToMap.

@Test
public void testApplyToMap() {
    Explode explode = new Explode(new FieldExpression("mapA"), "foo", "bar", false);
    ExplodeFunctor functor = new ExplodeFunctor(explode);
    List<BulletRecord> records = functor.apply(record, provider);
    Assert.assertEquals(records.size(), 3);
    Assert.assertEquals(records.get(0).fieldCount(), 2);
    Assert.assertEquals(records.get(0).typedGet("foo").getValue(), "a");
    Assert.assertEquals(records.get(0).typedGet("bar").getValue(), 0);
    Assert.assertEquals(records.get(1).fieldCount(), 2);
    Assert.assertEquals(records.get(1).typedGet("foo").getValue(), "b");
    Assert.assertEquals(records.get(1).typedGet("bar").getValue(), 1);
    Assert.assertEquals(records.get(2).fieldCount(), 2);
    Assert.assertEquals(records.get(2).typedGet("foo").getValue(), "c");
    Assert.assertEquals(records.get(2).typedGet("bar").getValue(), 2);
}
Also used : Explode(com.yahoo.bullet.query.tablefunctions.Explode) BulletRecord(com.yahoo.bullet.record.BulletRecord) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Aggregations

FieldExpression (com.yahoo.bullet.query.expressions.FieldExpression)63 Test (org.testng.annotations.Test)60 BinaryExpression (com.yahoo.bullet.query.expressions.BinaryExpression)33 BulletRecord (com.yahoo.bullet.record.BulletRecord)33 ValueExpression (com.yahoo.bullet.query.expressions.ValueExpression)30 Query (com.yahoo.bullet.query.Query)27 UnaryExpression (com.yahoo.bullet.query.expressions.UnaryExpression)15 Explode (com.yahoo.bullet.query.tablefunctions.Explode)15 Clip (com.yahoo.bullet.result.Clip)13 ArrayList (java.util.ArrayList)13 Projection (com.yahoo.bullet.query.Projection)12 Window (com.yahoo.bullet.query.Window)12 Raw (com.yahoo.bullet.query.aggregations.Raw)12 Expression (com.yahoo.bullet.query.expressions.Expression)12 BulletConfigTest (com.yahoo.bullet.common.BulletConfigTest)11 ListExpression (com.yahoo.bullet.query.expressions.ListExpression)11 Field (com.yahoo.bullet.query.Field)9 LateralView (com.yahoo.bullet.query.tablefunctions.LateralView)7 BulletConfig (com.yahoo.bullet.common.BulletConfig)6 RecordBox (com.yahoo.bullet.result.RecordBox)6