clintropolis commented on code in PR #16679:
URL: https://github.com/apache/druid/pull/16679#discussion_r1669740971
##########
extensions-core/datasketches/src/test/java/org/apache/druid/query/aggregation/datasketches/quantiles/sql/DoublesSketchSqlAggregatorTest.java:
##########
@@ -263,6 +269,143 @@ public void testQuantileOnComplexColumn()
);
}
+ @Test
+ public void testSubqueryWithNestedGroupBy()
+ {
+ final List<Object[]> expectedResults = ImmutableList.of(
+ new Object[]{946684800000L, "", 1L, "val1"},
+ new Object[]{946684800000L, "1", 1L, "val1"},
+ new Object[]{946684800000L, "10.1", 1L, "val1"},
+ new Object[]{946684800000L, "2", 1L, "val1"},
+ new Object[]{946684800000L, "abc", 1L, "val1"},
+ new Object[]{946684800000L, "def", 1L, "val1"}
+ );
+
+ testQuery(
+ "SELECT\n"
+ + " MILLIS_TO_TIMESTAMP(946684800000) AS __time,\n"
+ + " alias.\"user\",\n"
+ + " alias.days,\n"
+ + " (CASE WHEN alias.days < quantiles.first_quartile THEN 'val2' \n"
+ + " WHEN alias.days >= quantiles.first_quartile AND alias.days <
quantiles.third_quartile THEN 'val3' \n"
+ + " WHEN alias.days >= quantiles.third_quartile THEN 'val1' END) AS
val4\n"
+ + "FROM (\n"
+ + " SELECT\n"
+ + " APPROX_QUANTILE_DS(alias.days, 0.25) AS first_quartile,\n"
+ + " APPROX_QUANTILE_DS(alias.days, 0.75) AS third_quartile\n"
+ + " FROM (\n"
+ + " SELECT\n"
+ + " dim1 \"user\",\n"
+ + " COUNT(DISTINCT __time) AS days\n"
+ + " FROM \"foo\"\n"
+ + " GROUP BY 1\n"
+ + " ) AS alias\n"
+ + ") AS quantiles, (\n"
+ + " SELECT\n"
+ + " dim1 \"user\",\n"
+ + " COUNT(DISTINCT __time) AS days\n"
+ + " FROM \"foo\"\n"
+ + " GROUP BY 1\n"
+ + ") AS alias\n",
+ ImmutableMap.<String, Object>builder()
+ .putAll(QUERY_CONTEXT_DEFAULT)
+ .put(QueryContexts.MAX_SUBQUERY_BYTES_KEY, "100000")
+ // Disallows the fallback to row based limiting
+ .put(QueryContexts.MAX_SUBQUERY_ROWS_KEY, "10")
+ .build(),
+ ImmutableList.of(
+ newScanQueryBuilder()
+ .dataSource(
+ JoinDataSource.create(
+ new QueryDataSource(
+ GroupByQuery.builder()
+ .setDataSource(
+ new QueryDataSource(
+ GroupByQuery.builder()
+
.setDataSource("foo")
+
.setQuerySegmentSpec(querySegmentSpec(Intervals.ETERNITY))
+
.setGranularity(Granularities.ALL)
+ .addDimension(new
DefaultDimensionSpec(
+ "dim1",
+ "d0",
+
ColumnType.STRING
+ ))
+ .addAggregator(new
CardinalityAggregatorFactory(
Review Comment:
super nit: doesn't it feel kind of strange to be mixing non-datasketches
approx distinct count with datasketches extensions tests?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]