-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR aims to introduce Window functions on MSQ by doing the following: Introduce a Window querykit for handling window queries along with its factory and a processor for window queries If a window operator is present with a partition by clause, pushes the partition as a shuffle spec of the previous stage In presence of empty OVER() clause lets all operators loose on a single rac In presence of no empty OVER() clause, breaks down each window into individual stages Associated machinery to handle window functions in MSQ Introduced a separate hidden engine feature WINDOW_LEAF_OPERATOR which is set only for MSQ engine. In presence of this feature, the planner plans without the leaf operators by creating a window query over an inner scan query. In case of native this is set to false and the planner generates the leafOperators Guardrails around materialization Comprehensive UTs
- Loading branch information
1 parent
7649957
commit 524842a
Showing
44 changed files
with
3,550 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
...ge-query/src/main/java/org/apache/druid/msq/indexing/error/TooManyRowsInAWindowFault.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.druid.msq.indexing.error; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
import org.apache.druid.msq.util.MultiStageQueryContext; | ||
|
||
import java.util.Objects; | ||
|
||
@JsonTypeName(TooManyRowsInAWindowFault.CODE) | ||
public class TooManyRowsInAWindowFault extends BaseMSQFault | ||
{ | ||
|
||
static final String CODE = "TooManyRowsInAWindow"; | ||
|
||
private final int numRows; | ||
private final int maxRows; | ||
|
||
@JsonCreator | ||
public TooManyRowsInAWindowFault( | ||
@JsonProperty("numRows") final int numRows, | ||
@JsonProperty("maxRows") final int maxRows | ||
) | ||
{ | ||
super( | ||
CODE, | ||
"Too many rows in a window (requested = %d, max = %d). " | ||
+ " Try creating a window with a higher cardinality column or change the query shape." | ||
+ " Or you can change the max using query context param %s ." | ||
+ " Use it carefully as a higher value can lead to OutOfMemory errors. ", | ||
numRows, | ||
maxRows, | ||
MultiStageQueryContext.MAX_ROWS_MATERIALIZED_IN_WINDOW | ||
); | ||
this.numRows = numRows; | ||
this.maxRows = maxRows; | ||
} | ||
|
||
@JsonProperty | ||
public int getNumRows() | ||
{ | ||
return numRows; | ||
} | ||
|
||
@JsonProperty | ||
public int getMaxRows() | ||
{ | ||
return maxRows; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) | ||
{ | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
if (!super.equals(o)) { | ||
return false; | ||
} | ||
TooManyRowsInAWindowFault that = (TooManyRowsInAWindowFault) o; | ||
return numRows == that.numRows && maxRows == that.maxRows; | ||
} | ||
|
||
@Override | ||
public int hashCode() | ||
{ | ||
return Objects.hash(super.hashCode(), numRows, maxRows); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.