Search in sources :

Example 21 with SubstringDimExtractionFn

use of org.apache.druid.query.extraction.SubstringDimExtractionFn 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

SubstringDimExtractionFn (org.apache.druid.query.extraction.SubstringDimExtractionFn)21 Test (org.junit.Test)19 ExtractionDimensionSpec (org.apache.druid.query.dimension.ExtractionDimensionSpec)12 QueryDataSource (org.apache.druid.query.QueryDataSource)6 TableDataSource (org.apache.druid.query.TableDataSource)6 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)6 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)6 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)6 LongSumAggregatorFactory (org.apache.druid.query.aggregation.LongSumAggregatorFactory)5 Parameters (junitparams.Parameters)3 GlobalTableDataSource (org.apache.druid.query.GlobalTableDataSource)3 LookupDataSource (org.apache.druid.query.LookupDataSource)2 CardinalityAggregatorFactory (org.apache.druid.query.aggregation.cardinality.CardinalityAggregatorFactory)2 LikeDimFilter (org.apache.druid.query.filter.LikeDimFilter)2 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)2 ExpressionVirtualColumn (org.apache.druid.segment.virtual.ExpressionVirtualColumn)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 RexCall (org.apache.calcite.rex.RexCall)1 InputRow (org.apache.druid.data.input.InputRow)1