Search in sources :

Example 11 with ValueExpression

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

the class OrderByStrategyTest method testOrderByComputationWithSingleField.

@Test
public void testOrderByComputationWithSingleField() {
    OrderByStrategy orderByStrategy = makeOrderBy(Arrays.asList(new OrderBy.SortItem(new BinaryExpression(new FieldExpression("a"), new ValueExpression(-1), Operation.MUL), OrderBy.Direction.ASC), new OrderBy.SortItem(new BinaryExpression(new FieldExpression("b"), new ValueExpression(-1), Operation.MUL), OrderBy.Direction.ASC)));
    List<BulletRecord> records = new ArrayList<>();
    records.add(RecordBox.get().add("a", 5).add("b", 2).getRecord());
    records.add(RecordBox.get().add("a", 2).add("b", 4).getRecord());
    records.add(RecordBox.get().add("a", 2).add("b", 2).getRecord());
    records.add(RecordBox.get().add("a", 1).add("b", 7).getRecord());
    Clip clip = new Clip();
    clip.add(records);
    Clip result = orderByStrategy.execute(clip);
    Assert.assertEquals(result.getRecords().get(0).typedGet("a").getValue(), 5);
    Assert.assertEquals(result.getRecords().get(0).typedGet("b").getValue(), 2);
    Assert.assertEquals(result.getRecords().get(1).typedGet("a").getValue(), 2);
    Assert.assertEquals(result.getRecords().get(1).typedGet("b").getValue(), 4);
    Assert.assertEquals(result.getRecords().get(2).typedGet("a").getValue(), 2);
    Assert.assertEquals(result.getRecords().get(2).typedGet("b").getValue(), 2);
    Assert.assertEquals(result.getRecords().get(3).typedGet("a").getValue(), 1);
    Assert.assertEquals(result.getRecords().get(3).typedGet("b").getValue(), 7);
}
Also used : Clip(com.yahoo.bullet.result.Clip) BulletRecord(com.yahoo.bullet.record.BulletRecord) BinaryExpression(com.yahoo.bullet.query.expressions.BinaryExpression) ValueExpression(com.yahoo.bullet.query.expressions.ValueExpression) ArrayList(java.util.ArrayList) FieldExpression(com.yahoo.bullet.query.expressions.FieldExpression) Test(org.testng.annotations.Test)

Example 12 with ValueExpression

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

the class SimpleEqualityPartitionerTest method testDefaultPartitioningForQueryWthImproperBinaryEquals.

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

Example 13 with ValueExpression

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

the class SimpleEqualityPartitionerTest method testPartitioningForQueryWithNullCheckedFields.

@Test
public void testPartitioningForQueryWithNullCheckedFields() {
    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 14 with ValueExpression

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

the class SimpleEqualityPartitionerTest method testDefaultPartitioningQueryWithUnrelatedFilters.

@Test
public void testDefaultPartitioningQueryWithUnrelatedFilters() {
    SimpleEqualityPartitioner partitioner = createPartitioner("A", "B");
    Query query = createQuery(new BinaryExpression(new FieldExpression("C"), new ValueExpression("bar"), Operation.EQUALS), new BinaryExpression(new FieldExpression("D"), new ValueExpression("baz"), Operation.EQUALS));
    Assert.assertEquals(partitioner.getKeys(query), singleton("*-*"));
}
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 15 with ValueExpression

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

the class SimpleEqualityPartitionerTest method testDefaultPartitioningForQueryWithMultipleValues.

@Test
public void testDefaultPartitioningForQueryWithMultipleValues() {
    SimpleEqualityPartitioner partitioner = createPartitioner("A", "B");
    Query query = createQuery(new BinaryExpression(new FieldExpression("A"), new ValueExpression("foo"), Operation.EQUALS), new BinaryExpression(new FieldExpression("A"), new ValueExpression("bar"), Operation.EQUALS), new BinaryExpression(new FieldExpression("B"), new ValueExpression("baz"), Operation.EQUALS));
    Assert.assertEquals(partitioner.getKeys(query), singleton("*-*"));
}
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