pranavbhole commented on code in PR #14587:
URL: https://github.com/apache/druid/pull/14587#discussion_r1281306983
##########
sql/src/test/java/org/apache/druid/sql/calcite/CalciteArraysQueryTest.java:
##########
@@ -2888,6 +2888,234 @@ public void testUnnestTwiceWithFiltersAndExpressions()
);
}
+ @Test
+ public void testUnnestThriceWithFiltersOnDimAndUnnestCol()
+ {
+ cannotVectorize();
+ String sql = " SELECT dimZipf, dim3_unnest1, dim3_unnest2, dim3_unnest3
FROM \n"
+ + " ( SELECT * FROM \n"
+ + " ( SELECT * FROM lotsocolumns,
UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as ut(dim3_unnest1) )"
+ + " ,UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as
ut(dim3_unnest2) \n"
+ + " ), UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as
ut(dim3_unnest3) "
+ + " WHERE dimZipf=27 AND dim3_unnest1='Baz'";
+ testQuery(
+ sql,
+ QUERY_CONTEXT_UNNEST,
+ ImmutableList.of(
+ Druids.newScanQueryBuilder()
+ .dataSource(
+ UnnestDataSource.create(
+ UnnestDataSource.create(
+ UnnestDataSource.create(
+ new
TableDataSource(CalciteTests.DATASOURCE5),
+ expressionVirtualColumn(
+ "j0.unnest",
+ "\"dimMultivalEnumerated\"",
+ ColumnType.STRING
+ ),
+ null
+ ),
+ expressionVirtualColumn(
+ "_j0.unnest",
+ "\"dimMultivalEnumerated\"",
+ ColumnType.STRING
+ ), null
+ ),
+ expressionVirtualColumn(
+ "__j0.unnest",
+ "\"dimMultivalEnumerated\"",
+ ColumnType.STRING
+ ),
+ null
+ )
+ )
+ .intervals(querySegmentSpec(Filtration.eternity()))
+
.resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
+ .filters(and(
+ NullHandling.sqlCompatible()
+ ? equality("dimZipf", "27", ColumnType.LONG)
+ : bound("dimZipf", "27", "27", false, false, null,
StringComparators.NUMERIC),
+ equality("j0.unnest", "Baz", ColumnType.STRING)
+ ))
+ .legacy(false)
+ .context(QUERY_CONTEXT_UNNEST)
+ .columns(ImmutableList.of("__j0.unnest", "_j0.unnest",
"dimZipf", "j0.unnest"))
+ .build()
+ ),
+ ImmutableList.of(
+ new Object[]{"27", "Baz", "Baz", "Baz"},
+ new Object[]{"27", "Baz", "Baz", "Baz"},
+ new Object[]{"27", "Baz", "Baz", "Hello"},
+ new Object[]{"27", "Baz", "Baz", "World"},
+ new Object[]{"27", "Baz", "Baz", "Baz"},
+ new Object[]{"27", "Baz", "Baz", "Baz"},
+ new Object[]{"27", "Baz", "Baz", "Hello"},
+ new Object[]{"27", "Baz", "Baz", "World"},
+ new Object[]{"27", "Baz", "Hello", "Baz"},
+ new Object[]{"27", "Baz", "Hello", "Baz"},
+ new Object[]{"27", "Baz", "Hello", "Hello"},
+ new Object[]{"27", "Baz", "Hello", "World"},
+ new Object[]{"27", "Baz", "World", "Baz"},
+ new Object[]{"27", "Baz", "World", "Baz"},
+ new Object[]{"27", "Baz", "World", "Hello"},
+ new Object[]{"27", "Baz", "World", "World"},
+ new Object[]{"27", "Baz", "Baz", "Baz"},
+ new Object[]{"27", "Baz", "Baz", "Baz"},
+ new Object[]{"27", "Baz", "Baz", "Hello"},
+ new Object[]{"27", "Baz", "Baz", "World"},
+ new Object[]{"27", "Baz", "Baz", "Baz"},
+ new Object[]{"27", "Baz", "Baz", "Baz"},
+ new Object[]{"27", "Baz", "Baz", "Hello"},
+ new Object[]{"27", "Baz", "Baz", "World"},
+ new Object[]{"27", "Baz", "Hello", "Baz"},
+ new Object[]{"27", "Baz", "Hello", "Baz"},
+ new Object[]{"27", "Baz", "Hello", "Hello"},
+ new Object[]{"27", "Baz", "Hello", "World"},
+ new Object[]{"27", "Baz", "World", "Baz"},
+ new Object[]{"27", "Baz", "World", "Baz"},
+ new Object[]{"27", "Baz", "World", "Hello"},
+ new Object[]{"27", "Baz", "World", "World"}
+ )
+ );
+ }
+ @Test
+ public void testUnnestThriceWithFiltersOnDimAndAllUnnestColumns()
+ {
+ cannotVectorize();
+ String sql = " SELECT dimZipf, dim3_unnest1, dim3_unnest2, dim3_unnest3
FROM \n"
+ + " ( SELECT * FROM \n"
+ + " ( SELECT * FROM lotsocolumns,
UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as ut(dim3_unnest1) )"
+ + " ,UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as
ut(dim3_unnest2) \n"
+ + " ), UNNEST(MV_TO_ARRAY(dimMultivalEnumerated)) as
ut(dim3_unnest3) "
+ + " WHERE dimZipf=27 AND dim3_unnest1='Baz' AND
dim3_unnest2='Hello' AND dim3_unnest3='World'";
+ testQuery(
+ sql,
+ QUERY_CONTEXT_UNNEST,
+ ImmutableList.of(
+ Druids.newScanQueryBuilder()
+ .dataSource(
+ UnnestDataSource.create(
+ UnnestDataSource.create(
+ UnnestDataSource.create(
+ new
TableDataSource(CalciteTests.DATASOURCE5),
+ expressionVirtualColumn(
+ "j0.unnest",
+ "\"dimMultivalEnumerated\"",
+ ColumnType.STRING
+ ),
+ null
+ ),
+ expressionVirtualColumn(
+ "_j0.unnest",
+ "\"dimMultivalEnumerated\"",
+ ColumnType.STRING
+ ), equality("_j0.unnest", "Hello",
ColumnType.STRING)
+ ),
+ expressionVirtualColumn(
+ "__j0.unnest",
+ "\"dimMultivalEnumerated\"",
+ ColumnType.STRING
+ ),
+ equality("__j0.unnest", "World", ColumnType.STRING)
+ )
+ )
+ .intervals(querySegmentSpec(Filtration.eternity()))
+
.resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
+ .filters(and(
+ NullHandling.sqlCompatible()
+ ? equality("dimZipf", "27", ColumnType.LONG)
+ : bound("dimZipf", "27", "27", false, false, null,
StringComparators.NUMERIC),
Review Comment:
fixed
--
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]