use of com.yahoo.bullet.query.Query 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("*-*"));
}
use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.
the class QuerierTest method testTableFunction.
@Test
public void testTableFunction() {
TableFunction tableFunction = new LateralView(new Explode(new FieldExpression("map"), "key", "value", true));
Projection projection = new Projection(Arrays.asList(new Field("key", new FieldExpression("key")), new Field("value", new FieldExpression("value")), new Field("abc", new FieldExpression("abc"))), false);
Expression filter = new UnaryExpression(new FieldExpression("map"), Operation.IS_NOT_NULL);
Query query = new Query(tableFunction, projection, filter, new Raw(500), null, new Window(), null);
Querier querier = make(Querier.Mode.ALL, query);
querier.consume(RecordBox.get().addMap("map", Pair.of("a", 0), Pair.of("b", 1), Pair.of("c", 2)).add("abc", 1).getRecord());
querier.consume(RecordBox.get().add("abc", 2).getRecord());
querier.consume(RecordBox.get().add("abc", 3).add("map", new HashMap<>()).getRecord());
List<BulletRecord> result = querier.getResult().getRecords();
Assert.assertEquals(result.size(), 4);
Assert.assertEquals(result.get(0).fieldCount(), 3);
Assert.assertEquals(result.get(0).typedGet("key").getValue(), "a");
Assert.assertEquals(result.get(0).typedGet("value").getValue(), 0);
Assert.assertEquals(result.get(0).typedGet("abc").getValue(), 1);
Assert.assertEquals(result.get(1).fieldCount(), 3);
Assert.assertEquals(result.get(1).typedGet("key").getValue(), "b");
Assert.assertEquals(result.get(1).typedGet("value").getValue(), 1);
Assert.assertEquals(result.get(1).typedGet("abc").getValue(), 1);
Assert.assertEquals(result.get(2).fieldCount(), 3);
Assert.assertEquals(result.get(2).typedGet("key").getValue(), "c");
Assert.assertEquals(result.get(2).typedGet("value").getValue(), 2);
Assert.assertEquals(result.get(2).typedGet("abc").getValue(), 1);
Assert.assertEquals(result.get(3).fieldCount(), 1);
Assert.assertEquals(result.get(3).typedGet("abc").getValue(), 3);
}
use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.
the class QuerierTest method testNullConfig.
@Test(expectedExceptions = NullPointerException.class)
public void testNullConfig() {
RunningQuery query = makeRunningQuery("", new Query(new Projection(), null, new Raw(null), null, new Window(), null));
new Querier(query, null);
}
use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.
the class QuerierTest method testRawQueriesWithTimeWindowsAreNotChanged.
@Test
public void testRawQueriesWithTimeWindowsAreNotChanged() {
BulletConfig config = new BulletConfig();
Window window = WindowUtils.makeTumblingWindow(Integer.MAX_VALUE);
Query query = new Query(new Projection(), null, new Raw(null), null, window, null);
query.configure(config);
Querier querier = make(Querier.Mode.PARTITION, query, config);
Assert.assertFalse(querier.isClosed());
Assert.assertFalse(querier.shouldBuffer());
querier.consume(RecordBox.get().getRecord());
Assert.assertFalse(querier.isClosed());
Assert.assertEquals(querier.getWindow().getClass(), Tumbling.class);
}
use of com.yahoo.bullet.query.Query in project bullet-core by yahoo.
the class QuerierTest method testDisabledQueryMeta.
@Test
public void testDisabledQueryMeta() {
BulletConfig defaults = new BulletConfig();
defaults.set(BulletConfig.RESULT_METADATA_METRICS, Collections.emptyMap());
Query query = makeRawQuery();
query.configure(defaults);
Querier querier = make(Querier.Mode.ALL, "", query, defaults);
Assert.assertTrue(querier.getMetadata().asMap().isEmpty());
Clip result = querier.finish();
Assert.assertNotNull(result);
Assert.assertTrue(result.getRecords().isEmpty());
Assert.assertTrue(result.getMeta().asMap().isEmpty());
}
Aggregations