Search in sources :

Example 31 with ValueExpression

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

the class FieldTest method testToString.

@Test
public void testToString() {
    Field field = new Field("abc", new ValueExpression(5));
    Assert.assertEquals(field.toString(), "{name: abc, value: {value: 5, type: INTEGER}}");
}
Also used : ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) Test(org.testng.annotations.Test)

Example 32 with ValueExpression

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

the class ProjectionTest method testProjectionCopy.

@Test
public void testProjectionCopy() {
    Projection projection = new Projection(Arrays.asList(new Field("foo", new ValueExpression(5))), true);
    Assert.assertEquals(projection.getFields(), Collections.singletonList(new Field("foo", new ValueExpression(5))));
    Assert.assertEquals(projection.getType(), Projection.Type.COPY);
    Assert.assertEquals(projection.toString(), "{fields: [{name: foo, value: {value: 5, type: INTEGER}}], type: COPY}");
}
Also used : ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) Test(org.testng.annotations.Test)

Example 33 with ValueExpression

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

the class SimpleEqualityPartitioner method mapFieldsToValues.

private void mapFieldsToValues(Expression expression, Map<String, Set<Serializable>> mapping) {
    if (!(expression instanceof BinaryExpression)) {
        return;
    }
    BinaryExpression binary = (BinaryExpression) expression;
    if (binary.getOp() == Operation.AND) {
        mapFieldsToValues(binary.getLeft(), mapping);
        mapFieldsToValues(binary.getRight(), mapping);
    } else if (binary.getOp() == Operation.EQUALS) {
        if (binary.getLeft() instanceof FieldExpression && binary.getRight() instanceof ValueExpression) {
            addFieldToMapping((FieldExpression) binary.getLeft(), (ValueExpression) binary.getRight(), mapping);
        } else if (binary.getRight() instanceof FieldExpression && binary.getLeft() instanceof ValueExpression) {
            addFieldToMapping((FieldExpression) binary.getRight(), (ValueExpression) binary.getLeft(), mapping);
        }
    }
}
Also used : BinaryExpression(com.yahoo.bullet.query.expressions.BinaryExpression) ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression)

Example 34 with ValueExpression

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

the class SimpleEqualityPartitionerTest method testDefaultPartitioningQueryWithNullEqualityFilters.

@Test
public void testDefaultPartitioningQueryWithNullEqualityFilters() {
    SimpleEqualityPartitioner partitioner = createPartitioner("A", "B");
    Query query = createQuery(new BinaryExpression(new FieldExpression("A"), new ValueExpression(null), Operation.EQUALS), new BinaryExpression(new FieldExpression("B"), new ValueExpression(null), Operation.EQUALS));
    Assert.assertEquals(partitioner.getKeys(query), singleton("null-null"));
}
Also used : Query(com.yahoo.bullet.query.Query) BinaryExpression(com.yahoo.bullet.query.expressions.BinaryExpression) ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Example 35 with ValueExpression

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

the class SimpleEqualityPartitionerTest method testPartitioningForQueryWithAllFieldsOperandsFlipped.

@Test
public void testPartitioningForQueryWithAllFieldsOperandsFlipped() {
    SimpleEqualityPartitioner partitioner = createPartitioner("A", "B", "C");
    Query query = createQuery(new BinaryExpression(new ValueExpression("bar"), new FieldExpression("A"), Operation.EQUALS), new BinaryExpression(new ValueExpression("baz"), new FieldExpression("B"), Operation.EQUALS), new BinaryExpression(new ValueExpression("qux"), new FieldExpression("C"), Operation.EQUALS));
    Assert.assertEquals(partitioner.getKeys(query), singleton("bar.-baz.-qux."));
}
Also used : Query(com.yahoo.bullet.query.Query) BinaryExpression(com.yahoo.bullet.query.expressions.BinaryExpression) ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Aggregations

ValueExpression (com.yahoo.bullet.query.expressions.ValueExpression)42 Test (org.testng.annotations.Test)40 BinaryExpression (com.yahoo.bullet.query.expressions.BinaryExpression)29 FieldExpression (com.yahoo.bullet.query.expressions.FieldExpression)28 Query (com.yahoo.bullet.query.Query)23 UnaryExpression (com.yahoo.bullet.query.expressions.UnaryExpression)11 ListExpression (com.yahoo.bullet.query.expressions.ListExpression)10 BulletRecord (com.yahoo.bullet.record.BulletRecord)10 Projection (com.yahoo.bullet.query.Projection)9 Window (com.yahoo.bullet.query.Window)9 Raw (com.yahoo.bullet.query.aggregations.Raw)9 Expression (com.yahoo.bullet.query.expressions.Expression)9 BulletConfigTest (com.yahoo.bullet.common.BulletConfigTest)8 TypedObject (com.yahoo.bullet.typesystem.TypedObject)7 Field (com.yahoo.bullet.query.Field)6 BulletConfig (com.yahoo.bullet.common.BulletConfig)5 Clip (com.yahoo.bullet.result.Clip)5 Operation (com.yahoo.bullet.query.expressions.Operation)4 Computation (com.yahoo.bullet.query.postaggregations.Computation)4 RecordBox (com.yahoo.bullet.result.RecordBox)4