Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/_data/toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@
url: sql-reference/operational-commands
- title: Aggregate functions
url: sql-reference/aggregate-functions
- title: Window Functions
url: sql-reference/window-functions
- title: Numeric Functions
url: sql-reference/numeric-functions
- title: String Functions
Expand Down
27 changes: 27 additions & 0 deletions docs/_docs/sql-reference/window-functions.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.
= Window Functions

Ignite supports aggregate functions in the window form only for the following syntax:

[source,sql]
----
fun() OVER ([PARTITION BY <field> | <exp>])
----

The following constructs are not supported for window aggregates and will throw an exception:

- `ORDER BY` inside the `OVER(...)` clause;
- explicit window frame bounds (`ROWS`, `RANGE`, `BETWEEN ... AND ...`).
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public static IgniteRel optimize(SqlNode sqlNode, IgnitePlanner planner, IgniteL
// Transformation chain
rel = planner.transform(PlannerPhase.HEP_DECORRELATE, rel.getTraitSet(), rel);

rel = planner.transform(PlannerPhase.HEP_REWRITE_WINDOWS, rel.getTraitSet(), rel);

// RelOptUtil#propagateRelHints(RelNode, equiv) may skip hints because current RelNode has no hints.
// Or if hints reside in a child nodes which are not inputs of the current node. Like LogicalFlter#condition.
// Such hints may appear or be required below in the tree, after rules applying.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import org.apache.ignite.internal.processors.query.calcite.rule.ValuesConverterRule;
import org.apache.ignite.internal.processors.query.calcite.rule.logical.ExposeIndexRule;
import org.apache.ignite.internal.processors.query.calcite.rule.logical.FilterScanMergeRule;
import org.apache.ignite.internal.processors.query.calcite.rule.logical.IgniteLogicalWindowRewriteRule;
import org.apache.ignite.internal.processors.query.calcite.rule.logical.IgniteMultiJoinOptimizeRule;
import org.apache.ignite.internal.processors.query.calcite.rule.logical.LogicalOrToUnionRule;
import org.apache.ignite.internal.processors.query.calcite.rule.logical.ProjectScanMergeRule;
Expand Down Expand Up @@ -102,6 +103,23 @@ public enum PlannerPhase {
}
},

/** */
HEP_REWRITE_WINDOWS("Heuristic phase to rewrite window functions") {
/** {@inheritDoc} */
@Override public RuleSet getRules(PlanningContext ctx) {
return ctx.rules(RuleSets.ofList(
CoreRules.PROJECT_TO_LOGICAL_PROJECT_AND_WINDOW,
IgniteLogicalWindowRewriteRule.INSTANCE
)
);
}

/** {@inheritDoc} */
@Override public Program getProgram(PlanningContext ctx) {
return hep(getRules(ctx));
}
},

/** */
HEP_FILTER_PUSH_DOWN("Heuristic phase to push down filters") {
/** {@inheritDoc} */
Expand Down
Loading
Loading