Search in sources :

Example 1 with Raw

use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.

the class IdentityPubSubMessageSerDeTest method testConvertingQuery.

@Test
public void testConvertingQuery() {
    IdentityPubSubMessageSerDe serDe = new IdentityPubSubMessageSerDe(null);
    Query query = new Query(new Projection(), null, new Raw(1), null, new Window(), 1L);
    PubSubMessage actual = serDe.toMessage("id", query, "foo");
    Assert.assertEquals(actual.getId(), "id");
    Assert.assertSame(actual.getContent(), query);
    Assert.assertEquals(actual.getMetadata().getContent(), "foo");
}
Also used : Window(com.yahoo.bullet.query.Window) Query(com.yahoo.bullet.query.Query) Projection(com.yahoo.bullet.query.Projection) Raw(com.yahoo.bullet.query.aggregations.Raw) Test(org.testng.annotations.Test)

Example 2 with Raw

use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.

the class QueryTest method testValidateOuterQueryNoNestedOuterQuery.

@Test(expectedExceptions = BulletException.class, expectedExceptionsMessageRegExp = "Outer query cannot have an outer query\\.")
public void testValidateOuterQueryNoNestedOuterQuery() {
    Query nestedOuterQuery = new Query(new Projection(), null, new Raw(null), null, new Window(), null);
    Query outerQuery = new Query(null, new Projection(), null, new Raw(null), null, nestedOuterQuery, new Window(), null);
    new Query(null, new Projection(), null, new Raw(null), null, outerQuery, new Window(), null);
}
Also used : Raw(com.yahoo.bullet.query.aggregations.Raw) Test(org.testng.annotations.Test)

Example 3 with Raw

use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.

the class QueryTest method testDuration.

@Test
public void testDuration() {
    BulletConfig config = new BulletConfig();
    Query query = new Query(new Projection(), null, new Raw(null), null, new Window(), null);
    query.configure(config);
    Assert.assertEquals(query.getDuration(), (Long) BulletConfig.DEFAULT_QUERY_DURATION);
    query = new Query(new Projection(), null, new Raw(null), null, new Window(), -1000L);
    query.configure(config);
    Assert.assertEquals(query.getDuration(), (Long) BulletConfig.DEFAULT_QUERY_DURATION);
    query = new Query(new Projection(), null, new Raw(null), null, new Window(), 0L);
    query.configure(config);
    Assert.assertEquals(query.getDuration(), (Long) BulletConfig.DEFAULT_QUERY_DURATION);
    query = new Query(new Projection(), null, new Raw(null), null, new Window(), 1L);
    query.configure(config);
    Assert.assertEquals(query.getDuration(), (Long) 1L);
    query = new Query(new Projection(), null, new Raw(null), null, new Window(), BulletConfig.DEFAULT_QUERY_DURATION);
    query.configure(config);
    Assert.assertEquals(query.getDuration(), (Long) BulletConfig.DEFAULT_QUERY_DURATION);
    query = new Query(new Projection(), null, new Raw(null), null, new Window(), BulletConfig.DEFAULT_QUERY_MAX_DURATION);
    query.configure(config);
    Assert.assertEquals(query.getDuration(), (Long) BulletConfig.DEFAULT_QUERY_MAX_DURATION);
    // Overflow
    query = new Query(new Projection(), null, new Raw(null), null, new Window(), BulletConfig.DEFAULT_QUERY_MAX_DURATION * 2L);
    query.configure(config);
    Assert.assertEquals(query.getDuration(), (Long) BulletConfig.DEFAULT_QUERY_MAX_DURATION);
}
Also used : Raw(com.yahoo.bullet.query.aggregations.Raw) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 4 with Raw

use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.

the class QueryTest method testToString.

@Test
public void testToString() {
    BulletConfig config = new BulletConfig();
    config.set(BulletConfig.AGGREGATION_DEFAULT_SIZE, 1);
    config.set(BulletConfig.QUERY_DEFAULT_DURATION, 30000L);
    Query query = new Query(new Projection(), null, new Raw(null), null, new Window(), null);
    query.configure(config.validate());
    Assert.assertEquals(query.toString(), "{tableFunction: null, projection: {fields: null, type: PASS_THROUGH}, filter: null, " + "aggregation: {size: 1, type: RAW}, postAggregations: null, " + "window: {emitEvery: null, emitType: null, includeType: null, includeFirst: null}, " + "duration: 30000, outerQuery: null}");
}
Also used : Raw(com.yahoo.bullet.query.aggregations.Raw) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Example 5 with Raw

use of com.yahoo.bullet.query.aggregations.Raw in project bullet-core by yahoo.

the class QueryTest method testDefaults.

@Test
public void testDefaults() {
    Query query = new Query(new Projection(), null, new Raw(null), null, new Window(), null);
    BulletConfig config = new BulletConfig();
    query.configure(config);
    Assert.assertEquals(query.getDuration(), (Long) BulletConfig.DEFAULT_QUERY_DURATION);
    Assert.assertEquals(query.getAggregation().getSize(), (Integer) BulletConfig.DEFAULT_AGGREGATION_SIZE);
}
Also used : Raw(com.yahoo.bullet.query.aggregations.Raw) BulletConfig(com.yahoo.bullet.common.BulletConfig) Test(org.testng.annotations.Test)

Aggregations

Raw (com.yahoo.bullet.query.aggregations.Raw)40 Test (org.testng.annotations.Test)33 Projection (com.yahoo.bullet.query.Projection)27 Query (com.yahoo.bullet.query.Query)27 Window (com.yahoo.bullet.query.Window)26 BulletConfig (com.yahoo.bullet.common.BulletConfig)21 BulletConfigTest (com.yahoo.bullet.common.BulletConfigTest)17 FieldExpression (com.yahoo.bullet.query.expressions.FieldExpression)12 BinaryExpression (com.yahoo.bullet.query.expressions.BinaryExpression)11 ValueExpression (com.yahoo.bullet.query.expressions.ValueExpression)11 Expression (com.yahoo.bullet.query.expressions.Expression)10 ListExpression (com.yahoo.bullet.query.expressions.ListExpression)10 UnaryExpression (com.yahoo.bullet.query.expressions.UnaryExpression)10 BulletRecord (com.yahoo.bullet.record.BulletRecord)7 Field (com.yahoo.bullet.query.Field)6 Metadata (com.yahoo.bullet.pubsub.Metadata)5 RecordBox (com.yahoo.bullet.result.RecordBox)5 Operation (com.yahoo.bullet.query.expressions.Operation)3 Computation (com.yahoo.bullet.query.postaggregations.Computation)3 Culling (com.yahoo.bullet.query.postaggregations.Culling)3