ThirdEyeQueryExecutor { public ThirdEyeQueryResult executeQuery(String sql) throws Exception { return executeQuery(new ThirdEyeQueryParser(sql).getQuery()); } ThirdEyeQueryExecutor(ExecutorService executorService, StarTreeManager starTreeManager); ThirdEyeQueryResult executeQuery(String sql); ThirdEyeQueryResult executeQuery(final ThirdEyeQuery query); List<UUID> selectTreesToQuery(final Map<UUID, IndexMetadata> treeMetadataMap,
                                       final TimeRange queryTimeRange);  }
@Test public void testSimple_all() throws Exception { ThirdEyeQuery query = new ThirdEyeQuery() .setCollection(config.getCollection()) .setStart(start) .setEnd(end); ThirdEyeQueryResult result = queryExecutor.executeQuery(query); Assert.assertEquals(result.getData().size(), 1); DimensionKey key = new DimensionKey(new String[] { "*", "*", "*" }); MetricTimeSeries timeSeries = result.getData().get(key); Assert.assertNotNull(timeSeries); checkData(timeSeries, 256); }
@Test public void testGroupBy_simple() throws Exception { ThirdEyeQuery query = new ThirdEyeQuery() .setCollection(config.getCollection()) .setStart(start) .setEnd(end) .addGroupByColumn("A"); ThirdEyeQueryResult result = queryExecutor.executeQuery(query); System.out.println(result.getData()); Assert.assertEquals(result.getData().size(), 3); for (int i = 0; i < 2; i++) { DimensionKey key = new DimensionKey(new String[] { "A" + i, "*", "*" }); Assert.assertNotNull(result.getData().get(key)); checkData(result.getData().get(key), 128); } }
@Test public void testOr_simple() throws Exception { ThirdEyeQuery query = new ThirdEyeQuery() .setCollection(config.getCollection()) .setStart(start) .setEnd(end) .addDimensionValue("A", "A0") .addDimensionValue("A", "A1"); ThirdEyeQueryResult result = queryExecutor.executeQuery(query); Assert.assertEquals(result.getData().size(), 1); DimensionKey key = new DimensionKey(new String[] { "A0 OR A1", "*", "*" }); Assert.assertNotNull(result.getData().get(key)); checkData(result.getData().get(key), 256); }
@Test public void testGroupBy_includesOtherNode() throws Exception { ThirdEyeQuery query = new ThirdEyeQuery() .setCollection(config.getCollection()) .setStart(start) .setEnd(end) .addGroupByColumn("B"); ThirdEyeQueryResult result = queryExecutor.executeQuery(query); Assert.assertEquals(result.getData().size(), 5); for (int i = 0; i < 4; i++) { DimensionKey key = new DimensionKey(new String[]{ "*", "B" + i, "*"}); Assert.assertNotNull(result.getData().get(key)); checkData(result.getData().get(key), 64); } DimensionKey otherKey = new DimensionKey(new String[] { "*", "?", "*" }); Assert.assertNotNull(result.getData().get(otherKey)); checkData(result.getData().get(otherKey), 0); }