mirror of https://github.com/apache/druid.git
Fix: Do not require time condition on InlineDataSource (#11982)
For queries on logical values, e.g. SELECT 1337, we need not check for a filter on __time column even if requireTimeCondition is true.
This commit is contained in:
parent
c381cae51b
commit
b48f5a576b
|
@ -38,6 +38,7 @@ import org.apache.druid.java.util.common.Intervals;
|
||||||
import org.apache.druid.java.util.common.guava.Sequence;
|
import org.apache.druid.java.util.common.guava.Sequence;
|
||||||
import org.apache.druid.java.util.common.guava.Sequences;
|
import org.apache.druid.java.util.common.guava.Sequences;
|
||||||
import org.apache.druid.math.expr.Evals;
|
import org.apache.druid.math.expr.Evals;
|
||||||
|
import org.apache.druid.query.InlineDataSource;
|
||||||
import org.apache.druid.query.Query;
|
import org.apache.druid.query.Query;
|
||||||
import org.apache.druid.query.QueryToolChest;
|
import org.apache.druid.query.QueryToolChest;
|
||||||
import org.apache.druid.query.planning.DataSourceAnalysis;
|
import org.apache.druid.query.planning.DataSourceAnalysis;
|
||||||
|
@ -113,7 +114,8 @@ public class NativeQueryMaker implements QueryMaker
|
||||||
{
|
{
|
||||||
final Query<?> query = druidQuery.getQuery();
|
final Query<?> query = druidQuery.getQuery();
|
||||||
|
|
||||||
if (plannerContext.getPlannerConfig().isRequireTimeCondition()) {
|
if (plannerContext.getPlannerConfig().isRequireTimeCondition()
|
||||||
|
&& !(druidQuery.getDataSource() instanceof InlineDataSource)) {
|
||||||
if (Intervals.ONLY_ETERNITY.equals(findBaseDataSourceIntervals(query))) {
|
if (Intervals.ONLY_ETERNITY.equals(findBaseDataSourceIntervals(query))) {
|
||||||
throw new CannotBuildQueryException(
|
throw new CannotBuildQueryException(
|
||||||
"requireTimeCondition is enabled, all queries must include a filter condition on the __time column"
|
"requireTimeCondition is enabled, all queries must include a filter condition on the __time column"
|
||||||
|
|
|
@ -11335,6 +11335,29 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRequireTimeConditionLogicalValuePositive() throws Exception
|
||||||
|
{
|
||||||
|
testQuery(
|
||||||
|
PLANNER_CONFIG_REQUIRE_TIME_CONDITION,
|
||||||
|
"SELECT 2 + 2 AS a",
|
||||||
|
CalciteTests.REGULAR_USER_AUTH_RESULT,
|
||||||
|
ImmutableList.of(
|
||||||
|
newScanQueryBuilder()
|
||||||
|
.dataSource(InlineDataSource.fromIterable(
|
||||||
|
ImmutableList.of(new Object[]{4L}),
|
||||||
|
RowSignature.builder().add("a", ColumnType.LONG).build()
|
||||||
|
))
|
||||||
|
.columns("a")
|
||||||
|
.intervals(querySegmentSpec(Filtration.eternity()))
|
||||||
|
.resultFormat(ScanQuery.ResultFormat.RESULT_FORMAT_COMPACTED_LIST)
|
||||||
|
.context(QUERY_CONTEXT_DEFAULT)
|
||||||
|
.build()
|
||||||
|
),
|
||||||
|
ImmutableList.of(new Object[]{4})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRequireTimeConditionSimpleQueryNegative() throws Exception
|
public void testRequireTimeConditionSimpleQueryNegative() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue