From 6c7177714f9fe88c39eac6061e49d48cf38415f7 Mon Sep 17 00:00:00 2001 From: Rohan Garg <7731512+rohangarg@users.noreply.github.com> Date: Thu, 27 May 2021 10:50:39 +0530 Subject: [PATCH] Add test for join on __time column (#11289) --- .../druid/sql/calcite/CalciteQueryTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java index 48eb30318fa..1e32e765ab5 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java @@ -17491,4 +17491,36 @@ public class CalciteQueryTest extends BaseCalciteQueryTest ImmutableList.of() ); } + + @Test + public void testJoinWithTimeDimension() throws Exception + { + testQuery( + PLANNER_CONFIG_DEFAULT, + QUERY_CONTEXT_DEFAULT, + "SELECT count(*) FROM druid.foo t1 inner join druid.foo t2 on t1.__time = t2.__time", + CalciteTests.REGULAR_USER_AUTH_RESULT, + ImmutableList.of(Druids.newTimeseriesQueryBuilder() + .dataSource(JoinDataSource.create(new TableDataSource(CalciteTests.DATASOURCE1), + new QueryDataSource( + Druids.newScanQueryBuilder() + .dataSource(CalciteTests.DATASOURCE1) + .intervals(querySegmentSpec(Filtration.eternity())) + .resultFormat(ResultFormat.RESULT_FORMAT_COMPACTED_LIST) + .columns("__time") + .legacy(false) + .context(QUERY_CONTEXT_DEFAULT) + .build()), + "j0.", + "(\"__time\" == \"j0.__time\")", + JoinType.INNER, + null, + ExprMacroTable.nil())) + .intervals(querySegmentSpec(Filtration.eternity())) + .granularity(Granularities.ALL) + .aggregators(aggregators(new CountAggregatorFactory("a0"))) + .context(QUERY_CONTEXT_DEFAULT) + .build()), + ImmutableList.of(new Object[]{6L})); + } }