mirror of https://github.com/apache/druid.git
SQL: Include virtual columns used for filtering in ScanQuery. (#7472)
PR #6902 introduced the ability to use virtual columns for filters, but they were being omitted from "scan" queries, so filters would refer to a null column instead of the intended virtual column.
This commit is contained in:
parent
6789438a49
commit
721191635a
|
@ -1011,7 +1011,7 @@ public class DruidQuery
|
|||
return new ScanQuery(
|
||||
dataSource,
|
||||
filtration.getQuerySegmentSpec(),
|
||||
selectProjection != null ? VirtualColumns.create(selectProjection.getVirtualColumns()) : VirtualColumns.EMPTY,
|
||||
getVirtualColumns(true),
|
||||
ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST,
|
||||
0,
|
||||
scanLimit,
|
||||
|
|
|
@ -575,6 +575,30 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
|||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectWithExpressionFilter() throws Exception
|
||||
{
|
||||
testQuery(
|
||||
"SELECT dim1 FROM druid.foo WHERE m1 + 1 = 7",
|
||||
ImmutableList.of(
|
||||
newScanQueryBuilder()
|
||||
.dataSource(CalciteTests.DATASOURCE1)
|
||||
.intervals(querySegmentSpec(Filtration.eternity()))
|
||||
.virtualColumns(
|
||||
expressionVirtualColumn("v0", "(\"m1\" + 1)", ValueType.FLOAT)
|
||||
)
|
||||
.filters(selector("v0", "7", null))
|
||||
.columns("dim1")
|
||||
.resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||
.context(QUERY_CONTEXT_DEFAULT)
|
||||
.build()
|
||||
),
|
||||
ImmutableList.of(
|
||||
new Object[]{"abc"}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectStarWithLimitTimeDescending() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue