Search in sources :

Example 6 with StringLastAggregatorFactory

use of org.apache.druid.query.aggregation.last.StringLastAggregatorFactory in project druid by druid-io.

the class CalciteJoinQueryTest method testInnerJoinQueryOfLookup.

@Test
@Parameters(source = QueryContextForJoinProvider.class)
public void testInnerJoinQueryOfLookup(Map<String, Object> queryContext) throws Exception {
    // Cannot vectorize the subquery.
    cannotVectorize();
    testQuery("SELECT dim1, dim2, t1.v, t1.v\n" + "FROM foo\n" + "INNER JOIN \n" + "  (SELECT SUBSTRING(k, 1, 1) k, LATEST(v, 10) v FROM lookup.lookyloo GROUP BY 1) t1\n" + "  ON foo.dim2 = t1.k", queryContext, ImmutableList.of(newScanQueryBuilder().dataSource(join(new TableDataSource(CalciteTests.DATASOURCE1), new QueryDataSource(GroupByQuery.builder().setDataSource(new LookupDataSource("lookyloo")).setInterval(querySegmentSpec(Filtration.eternity())).setGranularity(Granularities.ALL).setDimensions(new ExtractionDimensionSpec("k", "d0", new SubstringDimExtractionFn(0, 1))).setAggregatorSpecs(new StringLastAggregatorFactory("a0", "v", null, 10)).build()), "j0.", equalsCondition(makeColumnExpression("dim2"), makeColumnExpression("j0.d0")), JoinType.INNER)).intervals(querySegmentSpec(Filtration.eternity())).columns("dim1", "dim2", "j0.a0").context(queryContext).build()), ImmutableList.of(new Object[] { "", "a", "xabc", "xabc" }, new Object[] { "1", "a", "xabc", "xabc" }));
}
Also used : SubstringDimExtractionFn(org.apache.druid.query.extraction.SubstringDimExtractionFn) GlobalTableDataSource(org.apache.druid.query.GlobalTableDataSource) TableDataSource(org.apache.druid.query.TableDataSource) QueryDataSource(org.apache.druid.query.QueryDataSource) LookupDataSource(org.apache.druid.query.LookupDataSource) StringLastAggregatorFactory(org.apache.druid.query.aggregation.last.StringLastAggregatorFactory) ExtractionDimensionSpec(org.apache.druid.query.dimension.ExtractionDimensionSpec) Parameters(junitparams.Parameters) Test(org.junit.Test)

Aggregations

StringLastAggregatorFactory (org.apache.druid.query.aggregation.last.StringLastAggregatorFactory)6 Test (org.junit.Test)6 LongAnyAggregatorFactory (org.apache.druid.query.aggregation.any.LongAnyAggregatorFactory)3 StringAnyAggregatorFactory (org.apache.druid.query.aggregation.any.StringAnyAggregatorFactory)3 LongFirstAggregatorFactory (org.apache.druid.query.aggregation.first.LongFirstAggregatorFactory)3 StringFirstAggregatorFactory (org.apache.druid.query.aggregation.first.StringFirstAggregatorFactory)3 LongLastAggregatorFactory (org.apache.druid.query.aggregation.last.LongLastAggregatorFactory)3 TableDataSource (org.apache.druid.query.TableDataSource)2 ExpressionLambdaAggregatorFactory (org.apache.druid.query.aggregation.ExpressionLambdaAggregatorFactory)2 FilteredAggregatorFactory (org.apache.druid.query.aggregation.FilteredAggregatorFactory)2 FinalizingFieldAccessPostAggregator (org.apache.druid.query.aggregation.post.FinalizingFieldAccessPostAggregator)2 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Parameters (junitparams.Parameters)1 JavaScriptConfig (org.apache.druid.js.JavaScriptConfig)1 GlobalTableDataSource (org.apache.druid.query.GlobalTableDataSource)1 LookupDataSource (org.apache.druid.query.LookupDataSource)1 QueryDataSource (org.apache.druid.query.QueryDataSource)1 Result (org.apache.druid.query.Result)1 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)1