Skip to content

Commit

Permalink
Make windowing off by default
Browse files Browse the repository at this point in the history
  • Loading branch information
imply-cheddar committed Dec 2, 2022
1 parent 851acb8 commit 299d735
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
23 changes: 15 additions & 8 deletions sql/src/main/java/org/apache/druid/sql/calcite/rel/DruidQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.apache.druid.query.DataSource;
import org.apache.druid.query.JoinDataSource;
import org.apache.druid.query.Query;
import org.apache.druid.query.QueryContext;
import org.apache.druid.query.QueryDataSource;
import org.apache.druid.query.aggregation.AggregatorFactory;
import org.apache.druid.query.aggregation.LongMaxAggregatorFactory;
Expand Down Expand Up @@ -273,14 +274,20 @@ public static DruidQuery fromPartialQuery(
}

if (partialQuery.getWindow() != null) {
windowing = Preconditions.checkNotNull(
Windowing.fromCalciteStuff(
partialQuery,
plannerContext,
sourceRowSignature, // TODO(gianm): window can only apply to the source data, because SCAN -> WINDOW
rexBuilder
)
);
final QueryContext queryContext = plannerContext.queryContext();
if (queryContext.getBoolean("windowsAreForClosers", false)) {
windowing = Preconditions.checkNotNull(
Windowing.fromCalciteStuff(
partialQuery,
plannerContext,
sourceRowSignature, // TODO(gianm): window can only apply to the source data, because SCAN -> WINDOW
rexBuilder
)
);
} else {
plannerContext.setPlanningError("Windowing Not Currently Supported");
throw new CannotBuildQueryException("Windowing Not Currently Supported");
}
} else {
windowing = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.collect.ImmutableMap;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import junitparams.naming.TestCaseName;
Expand Down Expand Up @@ -130,6 +131,7 @@ public void windowQueryTest(String filename) throws IOException
testBuilder()
.skipVectorize(true)
.sql(input.sql)
.queryContext(ImmutableMap.of("windowsAreForClosers", true))
.addCustomVerification(QueryVerification.ofResults(results -> {
if (results.exception != null) {
throw new RE(results.exception, "Failed to execute because of exception.");
Expand Down

0 comments on commit 299d735

Please sign in to comment.