You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by sh...@apache.org on 2016/06/24 21:09:25 UTC
incubator-quickstep git commit: Addressed comment issues
Repository: incubator-quickstep
Updated Branches:
refs/heads/SQL-window-aggregation 0210099e0 -> 95707b0ce
Addressed comment issues
Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/95707b0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/95707b0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/95707b0c
Branch: refs/heads/SQL-window-aggregation
Commit: 95707b0ce77ad95cb30f0871dd5a6a8897109ae6
Parents: 0210099
Author: shixuan-fan <sh...@apache.org>
Authored: Fri Jun 24 21:09:07 2016 +0000
Committer: shixuan-fan <sh...@apache.org>
Committed: Fri Jun 24 21:09:07 2016 +0000
----------------------------------------------------------------------
.../expressions/WindowAggregateFunction.cpp | 8 +-
.../expressions/WindowAggregateFunction.hpp | 26 +--
query_optimizer/logical/WindowAggregate.cpp | 2 +-
query_optimizer/logical/WindowAggregate.hpp | 12 +-
query_optimizer/resolver/Resolver.cpp | 168 ++++++-------------
query_optimizer/resolver/Resolver.hpp | 6 +-
.../tests/logical_generator/Select.test | 42 ++---
query_optimizer/tests/resolver/Select.test | 42 ++---
8 files changed, 118 insertions(+), 188 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/95707b0c/query_optimizer/expressions/WindowAggregateFunction.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/WindowAggregateFunction.cpp b/query_optimizer/expressions/WindowAggregateFunction.cpp
index 5cab5d6..7b1f304 100644
--- a/query_optimizer/expressions/WindowAggregateFunction.cpp
+++ b/query_optimizer/expressions/WindowAggregateFunction.cpp
@@ -61,8 +61,8 @@ const Type& WindowAggregateFunction::getValueType() const {
WindowAggregateFunctionPtr WindowAggregateFunction::Create(
const ::quickstep::AggregateFunction &window_aggregate,
const std::vector<ScalarPtr> &arguments,
- const WindowInfo window_info,
- const std::string window_name,
+ const WindowInfo &window_info,
+ const std::string &window_name,
const bool is_distinct) {
#ifdef QUICKSTEP_DEBUG
std::vector<const Type*> argument_types;
@@ -141,7 +141,7 @@ void WindowAggregateFunction::getFieldStringItems(
inline_field_names->push_back("is_ascending");
std::string ascending_list("[");
- for (bool is_ascending : window_info_.order_by_directions) {
+ for (const bool is_ascending : window_info_.order_by_directions) {
if (is_ascending) {
ascending_list.append("true,");
} else {
@@ -156,7 +156,7 @@ void WindowAggregateFunction::getFieldStringItems(
inline_field_names->push_back("nulls_first");
std::string nulls_first_flags("[");
- for (bool nulls_first_flag : window_info_.nulls_first) {
+ for (const bool nulls_first_flag : window_info_.nulls_first) {
if (nulls_first_flag) {
nulls_first_flags.append("true,");
} else {
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/95707b0c/query_optimizer/expressions/WindowAggregateFunction.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/WindowAggregateFunction.hpp b/query_optimizer/expressions/WindowAggregateFunction.hpp
index 319dccd..0bee28f 100644
--- a/query_optimizer/expressions/WindowAggregateFunction.hpp
+++ b/query_optimizer/expressions/WindowAggregateFunction.hpp
@@ -54,9 +54,9 @@ struct WindowFrameInfo {
* @param num_following_in The number of following tuples the window frame
* will cover, -1 means UNBOUNDED.
**/
- explicit WindowFrameInfo(const bool is_row_in,
- const int num_preceding_in,
- const int num_following_in)
+ WindowFrameInfo(const bool is_row_in,
+ const int num_preceding_in,
+ const int num_following_in)
: is_row(is_row_in),
num_preceding(num_preceding_in),
num_following(num_following_in) {}
@@ -77,11 +77,11 @@ struct WindowInfo {
* @param frame_info_in The window frame information for the window. Null
* means there is no explicit window frame definition.
**/
- explicit WindowInfo(const std::vector<AttributeReferencePtr> &partition_by_attributes_in,
- const std::vector<AttributeReferencePtr> &order_by_attributes_in,
- const std::vector<bool> &order_by_directions_in,
- const std::vector<bool> &nulls_first_in,
- const WindowFrameInfo *frame_info_in)
+ WindowInfo(const std::vector<AttributeReferencePtr> &partition_by_attributes_in,
+ const std::vector<AttributeReferencePtr> &order_by_attributes_in,
+ const std::vector<bool> &order_by_directions_in,
+ const std::vector<bool> &nulls_first_in,
+ const WindowFrameInfo *frame_info_in)
: partition_by_attributes(partition_by_attributes_in),
order_by_attributes(order_by_attributes_in),
order_by_directions(order_by_directions_in),
@@ -187,8 +187,8 @@ class WindowAggregateFunction : public Expression {
**/
static WindowAggregateFunctionPtr Create(const ::quickstep::AggregateFunction &window_aggregate,
const std::vector<ScalarPtr> &arguments,
- const WindowInfo window_info,
- const std::string window_name,
+ const WindowInfo &window_info,
+ const std::string &window_name,
const bool is_distinct);
protected:
@@ -211,8 +211,8 @@ class WindowAggregateFunction : public Expression {
*/
WindowAggregateFunction(const ::quickstep::AggregateFunction &window_aggregate,
const std::vector<ScalarPtr> &arguments,
- const WindowInfo window_info,
- const std::string window_name,
+ const WindowInfo &window_info,
+ const std::string &window_name,
const bool is_distinct)
: window_aggregate_(window_aggregate),
arguments_(arguments),
@@ -243,4 +243,4 @@ class WindowAggregateFunction : public Expression {
} // namespace optimizer
} // namespace quickstep
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_EXPRESSIONS_WINDOW_AGGREGATE_FUNCTION_HPP_ */
+#endif // QUICKSTEP_QUERY_OPTIMIZER_EXPRESSIONS_WINDOW_AGGREGATE_FUNCTION_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/95707b0c/query_optimizer/logical/WindowAggregate.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/logical/WindowAggregate.cpp b/query_optimizer/logical/WindowAggregate.cpp
index 4dc787b..0d747b6 100644
--- a/query_optimizer/logical/WindowAggregate.cpp
+++ b/query_optimizer/logical/WindowAggregate.cpp
@@ -57,7 +57,7 @@ std::vector<E::AttributeReferencePtr> WindowAggregate::getReferencedAttributes()
LogicalPtr WindowAggregate::copyWithNewInputExpressions(
const std::vector<E::ExpressionPtr> &input_expressions) const {
// Only one expression needed
- DCHECK_EQ(input_expressions.size(), static_cast<std::uint32_t>(1));
+ DCHECK_EQ(1u, input_expressions.size());
E::AliasPtr window_aggregate_expression;
E::SomeAlias::MatchesWithConditionalCast(input_expressions[0],
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/95707b0c/query_optimizer/logical/WindowAggregate.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/logical/WindowAggregate.hpp b/query_optimizer/logical/WindowAggregate.hpp
index 09946a4..dcd9a7d 100644
--- a/query_optimizer/logical/WindowAggregate.hpp
+++ b/query_optimizer/logical/WindowAggregate.hpp
@@ -85,8 +85,8 @@ class WindowAggregate : public Logical {
* @return An immutable WindowAggregate node.
*/
static WindowAggregatePtr Create(
- LogicalPtr input,
- const expressions::AliasPtr window_aggregate_expression) {
+ const LogicalPtr &input,
+ const expressions::AliasPtr &window_aggregate_expression) {
return WindowAggregatePtr(new WindowAggregate(input, window_aggregate_expression));
}
@@ -100,15 +100,15 @@ class WindowAggregate : public Logical {
std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
private:
- WindowAggregate(LogicalPtr input,
- const expressions::AliasPtr window_aggregate_expression)
+ WindowAggregate(const LogicalPtr &input,
+ const expressions::AliasPtr &window_aggregate_expression)
: input_(input),
window_aggregate_expression_(window_aggregate_expression) {
addChild(input_);
addInputExpression(window_aggregate_expression_);
}
- LogicalPtr input_;
+ const LogicalPtr input_;
const expressions::AliasPtr window_aggregate_expression_;
DISALLOW_COPY_AND_ASSIGN(WindowAggregate);
@@ -120,4 +120,4 @@ class WindowAggregate : public Logical {
} // namespace optimizer
} // namespace quickstep
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_AGGREGATE_HPP_ */
+#endif // QUICKSTEP_QUERY_OPTIMIZER_LOGICAL_WINDOW_AGGREGATE_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/95707b0c/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index bcd0357..f880ce7 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -228,8 +228,8 @@ struct Resolver::QueryAggregationInfo {
};
struct Resolver::WindowPlan {
- explicit WindowPlan(E::WindowInfo window_info_in,
- L::LogicalPtr logical_plan_in)
+ WindowPlan(const E::WindowInfo &window_info_in,
+ const L::LogicalPtr &logical_plan_in)
: window_info(window_info_in),
logical_plan(logical_plan_in) {}
@@ -238,7 +238,7 @@ struct Resolver::WindowPlan {
};
struct Resolver::WindowAggregationInfo {
- explicit WindowAggregationInfo(const std::unordered_map<std::string, WindowPlan> window_map_in)
+ explicit WindowAggregationInfo(const std::unordered_map<std::string, WindowPlan> &window_map_in)
: window_map(window_map_in) {}
// Whether the current query block has a GROUP BY.
@@ -1016,7 +1016,7 @@ L::LogicalPtr Resolver::resolveSelect(
if (select_query.window_list() != nullptr) {
if (select_query.window_list()->size() > 1) {
THROW_SQL_ERROR_AT(&(*select_query.window_list()->begin()))
- << "Currently we don't support multiple window aggregation functions";
+ << "Currently we don't support multiple window aggregation functions";
}
// Sort the table according to the window.
@@ -1060,7 +1060,7 @@ L::LogicalPtr Resolver::resolveSelect(
has_aggregate_per_expression);
// Create window aggregate node if needed
- for (E::AliasPtr alias : window_aggregation_info.window_aggregate_expressions) {
+ for (const E::AliasPtr &alias : window_aggregation_info.window_aggregate_expressions) {
E::WindowAggregateFunctionPtr window_aggregate_function;
if (!E::SomeWindowAggregateFunction::MatchesWithConditionalCast(alias->expression(),
&window_aggregate_function)) {
@@ -1071,7 +1071,7 @@ L::LogicalPtr Resolver::resolveSelect(
// Get the sorted logical plan
const std::string window_name = window_aggregate_function->window_name();
- if (window_name != "") {
+ if (!window_name.empty()) {
sorted_logical_plan = sorted_window_map.at(window_name).logical_plan;
} else {
sorted_logical_plan = resolveSortInWindow(logical_plan,
@@ -1690,8 +1690,8 @@ E::WindowInfo Resolver::resolveWindow(const ParseWindow &parse_window,
if (parse_window.frame_info() != nullptr) {
const quickstep::ParseFrameInfo *parse_frame_info = parse_window.frame_info();
frame_info = new E::WindowFrameInfo(parse_frame_info->is_row,
- parse_frame_info->num_preceding,
- parse_frame_info->num_following);
+ parse_frame_info->num_preceding,
+ parse_frame_info->num_following);
}
return E::WindowInfo(partition_by_attributes,
@@ -2573,13 +2573,7 @@ E::ScalarPtr Resolver::resolveSimpleCaseExpression(
E::ScalarPtr Resolver::resolveFunctionCall(
const ParseFunctionCall &parse_function_call,
ExpressionResolutionInfo *expression_resolution_info) {
- // Check if it is a window function.
- if (parse_function_call.isWindow()) {
- return resolveWindowAggregateFunction(parse_function_call,
- expression_resolution_info);
- }
-
- std::string function_name = ToLower(parse_function_call.name()->value());
+ const std::string function_name = ToLower(parse_function_call.name()->value());
// First check for the special case COUNT(*).
bool count_star = false;
@@ -2594,8 +2588,9 @@ E::ScalarPtr Resolver::resolveFunctionCall(
std::vector<E::ScalarPtr> resolved_arguments;
const PtrList<ParseExpression> *unresolved_arguments =
parse_function_call.arguments();
- // The first aggregate function in the arguments.
+ // The first aggregate function and window aggregate function in the arguments.
const ParseTreeNode *first_aggregate_function = nullptr;
+ const ParseTreeNode *first_window_aggregate_function = nullptr;
if (unresolved_arguments != nullptr) {
for (const ParseExpression &unresolved_argument : *unresolved_arguments) {
ExpressionResolutionInfo expr_resolution_info(
@@ -2609,6 +2604,13 @@ E::ScalarPtr Resolver::resolveFunctionCall(
first_aggregate_function =
expr_resolution_info.parse_aggregate_expression;
}
+
+ if (expr_resolution_info.hasWindowAggregate() &&
+ first_window_aggregate_function == nullptr &&
+ parse_function_call.isWindow()) {
+ first_window_aggregate_function =
+ expr_resolution_info.parse_window_aggregate_expression;
+ }
}
}
@@ -2639,6 +2641,15 @@ E::ScalarPtr Resolver::resolveFunctionCall(
<< "Aggregation of Aggregates are not allowed";
}
+ // TODO(Shixuan): We currently don't support nested window aggregation since
+ // TPC-DS doesn't have that. However, it is essentially a nested scalar
+ // function, which should be supported in the future version of Quickstep.
+ if (parse_function_call.isWindow() &&
+ first_window_aggregate_function != nullptr) {
+ THROW_SQL_ERROR_AT(first_window_aggregate_function)
+ << "Window aggregation of window aggregates is not allowed";
+ }
+
// Make sure a naked COUNT() with no arguments wasn't specified.
if ((aggregate->getAggregationID() == AggregationID::kCount)
&& (resolved_arguments.empty())
@@ -2660,6 +2671,13 @@ E::ScalarPtr Resolver::resolveFunctionCall(
<< " can not apply to the given argument(s).";
}
+ if (parse_function_call.isWindow()) {
+ return resolveWindowAggregateFunction(parse_function_call,
+ expression_resolution_info,
+ aggregate,
+ resolved_arguments);
+ }
+
// Create the optimizer representation of the resolved aggregate and an alias
// for it to appear in the output relation.
const E::AggregateFunctionPtr aggregate_function
@@ -2681,106 +2699,9 @@ E::ScalarPtr Resolver::resolveFunctionCall(
E::ScalarPtr Resolver::resolveWindowAggregateFunction(
const ParseFunctionCall &parse_function_call,
- ExpressionResolutionInfo *expression_resolution_info) {
- if (!expression_resolution_info->window_aggregation_info->window_aggregate_expressions.empty()) {
- THROW_SQL_ERROR_AT(&parse_function_call)
- << "Currently we only support single window aggregate in the query";
- }
-
- std::string function_name = ToLower(parse_function_call.name()->value());
-
- // First check for the special case COUNT(*).
- bool count_star = false;
- if (parse_function_call.star() != nullptr) {
- if (function_name != "count") {
- THROW_SQL_ERROR_AT(parse_function_call.star())
- << "Only COUNT can have star (*) as an argument";
- }
- count_star = true;
- }
-
- std::vector<E::ScalarPtr> resolved_arguments;
- const PtrList<ParseExpression> *unresolved_arguments =
- parse_function_call.arguments();
- // The first aggregate function in the arguments.
- const ParseTreeNode *first_aggregate_function = nullptr;
- const ParseTreeNode *first_window_aggregate_function = nullptr;
- if (unresolved_arguments != nullptr) {
- for (const ParseExpression &unresolved_argument : *unresolved_arguments) {
- ExpressionResolutionInfo expr_resolution_info(
- *expression_resolution_info);
- resolved_arguments.push_back(
- resolveExpression(unresolved_argument,
- nullptr, // No Type hint.
- &expr_resolution_info));
-
- // We don't allow aggregate or window aggregate nested in a window
- // aggregate function.
- if (expr_resolution_info.hasAggregate() &&
- first_aggregate_function == nullptr) {
- first_aggregate_function =
- expr_resolution_info.parse_aggregate_expression;
- }
-
- if (expr_resolution_info.hasWindowAggregate() &&
- first_window_aggregate_function == nullptr) {
- first_window_aggregate_function =
- expr_resolution_info.parse_window_aggregate_expression;
- }
- }
- }
-
- if (count_star && !resolved_arguments.empty()) {
- THROW_SQL_ERROR_AT(&parse_function_call)
- << "COUNT aggregate has both star (*) and non-star arguments.";
- }
-
- // Try to look up the AggregateFunction by name using
- // AggregateFunctionFactory.
- const ::quickstep::AggregateFunction *window_aggregate
- = AggregateFunctionFactory::GetByName(function_name);
- if (window_aggregate == nullptr) {
- THROW_SQL_ERROR_AT(&parse_function_call)
- << "Unrecognized function name \""
- << parse_function_call.name()->value()
- << "\"";
- }
-
- // Make sure aggregates are allowed in this context.
- if (first_aggregate_function != nullptr) {
- THROW_SQL_ERROR_AT(first_aggregate_function)
- << "Window aggregation of aggregates is not allowed";
- }
-
- // TODO(Shixuan): We currently don't support nested window aggregation since
- // TPC-DS doesn't have that. However, it is essentially a nested scalar
- // function, which should be supported in the future version of Quickstep.
- if (first_window_aggregate_function != nullptr) {
- THROW_SQL_ERROR_AT(first_window_aggregate_function)
- << "Window aggregation of window aggregates is not allowed";
- }
-
- // Make sure a naked COUNT() with no arguments wasn't specified.
- if ((window_aggregate->getAggregationID() == AggregationID::kCount)
- && (resolved_arguments.empty())
- && (!count_star)) {
- THROW_SQL_ERROR_AT(&parse_function_call)
- << "COUNT aggregate requires an argument (either scalar or star (*))";
- }
-
- // Resolve each of the Scalar arguments to the aggregate.
- std::vector<const Type*> argument_types;
- for (const E::ScalarPtr &argument : resolved_arguments) {
- argument_types.emplace_back(&argument->getValueType());
- }
-
- // Make sure that the aggregate can apply to the specified argument(s).
- if (!window_aggregate->canApplyToTypes(argument_types)) {
- THROW_SQL_ERROR_AT(&parse_function_call)
- << "Aggregate function " << window_aggregate->getName()
- << " can not apply to the given argument(s).";
- }
-
+ ExpressionResolutionInfo *expression_resolution_info,
+ const ::quickstep::AggregateFunction *window_aggregate,
+ const std::vector<E::ScalarPtr> &resolved_arguments) {
// A window aggregate function might be defined OVER a window name or a window.
E::WindowAggregateFunctionPtr window_aggregate_function;
if (parse_function_call.window_name() != nullptr) {
@@ -2792,7 +2713,7 @@ E::ScalarPtr Resolver::resolveWindowAggregateFunction(
if (map_it == window_map.end()) {
THROW_SQL_ERROR_AT(parse_function_call.window_name())
- << "Undefined window " << window_name;
+ << "Undefined window " << window_name;
}
window_aggregate_function =
@@ -2821,6 +2742,11 @@ E::ScalarPtr Resolver::resolveWindowAggregateFunction(
internal_alias,
"$window_aggregate" /* relation_name */);
+ if (!expression_resolution_info->window_aggregation_info->window_aggregate_expressions.empty()) {
+ THROW_SQL_ERROR_AT(&parse_function_call)
+ << "Currently we only support single window aggregate in the query";
+ }
+
expression_resolution_info->window_aggregation_info
->window_aggregate_expressions.emplace_back(aggregate_alias);
expression_resolution_info->parse_window_aggregate_expression = &parse_function_call;
@@ -3151,19 +3077,19 @@ void Resolver::rewriteIfOrdinalReference(
}
std::string Resolver::GenerateWindowAggregateAttributeAlias(int index) {
- return std::string("$window_aggregate").append(std::to_string(index));
+ return "$window_aggregate" + std::to_string(index);
}
std::string Resolver::GenerateAggregateAttributeAlias(int index) {
- return std::string("$aggregate").append(std::to_string(index));
+ return "$aggregate" + std::to_string(index);
}
std::string Resolver::GenerateGroupingAttributeAlias(int index) {
- return std::string("$groupby").append(std::to_string(index));
+ return "$groupby" + std::to_string(index);
}
std::string Resolver::GenerateOrderingAttributeAlias(int index) {
- return std::string("$orderby").append(std::to_string(index));
+ return "$orderby" + std::to_string(index);
}
} // namespace resolver
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/95707b0c/query_optimizer/resolver/Resolver.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.hpp b/query_optimizer/resolver/Resolver.hpp
index 7d597e9..f4024e9 100644
--- a/query_optimizer/resolver/Resolver.hpp
+++ b/query_optimizer/resolver/Resolver.hpp
@@ -460,11 +460,15 @@ class Resolver {
* @param expression_resolution_info Resolution info that contains the name
* resolver and info to be updated after
* resolution.
+ * @param aggregate The aggregate function.
+ * @param resolved_arguments The resolved arguments.
* @return An expression in the query optimizer.
*/
expressions::ScalarPtr resolveWindowAggregateFunction(
const ParseFunctionCall &parse_function_call,
- ExpressionResolutionInfo *expression_resolution_info);
+ ExpressionResolutionInfo *expression_resolution_info,
+ const ::quickstep::AggregateFunction *aggregate,
+ const std::vector<expressions::ScalarPtr> &resolved_arguments);
/**
* @brief Resolves a parse Predicate and converts it to a predicate in the
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/95707b0c/query_optimizer/tests/logical_generator/Select.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/logical_generator/Select.test b/query_optimizer/tests/logical_generator/Select.test
index e6b664d..e0003bf 100644
--- a/query_optimizer/tests/logical_generator/Select.test
+++ b/query_optimizer/tests/logical_generator/Select.test
@@ -1447,27 +1447,6 @@ TopLevelPlan
type=Double NULL]
==
-SELECT int_col, sum(float_col) OVER w1 FROM test
-WINDOW w2 AS
-(PARTITION BY vchar_col, long_col
- ORDER BY double_col DESC NULLS LAST, int_col ASC NULLS FIRST
- RANGE BETWEEN 3 PRECEDING AND 3 FOLLOWING);
---
-ERROR: Undefined window w1 (1 : 37)
-SELECT int_col, sum(float_col) OVER w1 FROM test
- ^
-==
-
-SELECT sum(avg(int_col)) OVER w FROM test
-WINDOW w AS
-(PARTITION BY double_col
- ORDER BY char_col)
---
-ERROR: Window aggregation of aggregates is not allowed (1 : 12)
-SELECT sum(avg(int_col)) OVER w FROM test
- ^
-==
-
SELECT sum(avg(int_col) OVER w) FROM test
WINDOW w AS
(PARTITION BY char_col
@@ -1516,3 +1495,24 @@ TopLevelPlan
+-output_attributes=
+-AttributeReference[id=7,name=,alias=sum(avg(int_col)),relation=,
type=Double NULL]
+==
+
+SELECT int_col, sum(float_col) OVER w1 FROM test
+WINDOW w2 AS
+(PARTITION BY vchar_col, long_col
+ ORDER BY double_col DESC NULLS LAST, int_col ASC NULLS FIRST
+ RANGE BETWEEN 3 PRECEDING AND 3 FOLLOWING);
+--
+ERROR: Undefined window w1 (1 : 37)
+SELECT int_col, sum(float_col) OVER w1 FROM test
+ ^
+==
+
+SELECT sum(avg(int_col)) OVER w FROM test
+WINDOW w AS
+(PARTITION BY double_col
+ ORDER BY char_col)
+--
+ERROR: Aggregation of Aggregates are not allowed (1 : 12)
+SELECT sum(avg(int_col)) OVER w FROM test
+ ^
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/95707b0c/query_optimizer/tests/resolver/Select.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/resolver/Select.test b/query_optimizer/tests/resolver/Select.test
index 6a5b608..89ab84d 100644
--- a/query_optimizer/tests/resolver/Select.test
+++ b/query_optimizer/tests/resolver/Select.test
@@ -3219,27 +3219,6 @@ TopLevelPlan
type=Double NULL]
==
-SELECT int_col, sum(float_col) OVER w1 FROM test
-WINDOW w2 AS
-(PARTITION BY vchar_col, long_col
- ORDER BY double_col DESC NULLS LAST, int_col ASC NULLS FIRST
- RANGE BETWEEN 3 PRECEDING AND 3 FOLLOWING);
---
-ERROR: Undefined window w1 (1 : 37)
-SELECT int_col, sum(float_col) OVER w1 FROM test
- ^
-==
-
-SELECT sum(avg(int_col)) OVER w FROM test
-WINDOW w AS
-(PARTITION BY double_col
- ORDER BY char_col)
---
-ERROR: Window aggregation of aggregates is not allowed (1 : 12)
-SELECT sum(avg(int_col)) OVER w FROM test
- ^
-==
-
SELECT sum(avg(int_col) OVER w) FROM test
WINDOW w AS
(PARTITION BY char_col
@@ -3288,3 +3267,24 @@ TopLevelPlan
+-output_attributes=
+-AttributeReference[id=7,name=,alias=sum(avg(int_col)),relation=,
type=Double NULL]
+==
+
+SELECT int_col, sum(float_col) OVER w1 FROM test
+WINDOW w2 AS
+(PARTITION BY vchar_col, long_col
+ ORDER BY double_col DESC NULLS LAST, int_col ASC NULLS FIRST
+ RANGE BETWEEN 3 PRECEDING AND 3 FOLLOWING);
+--
+ERROR: Undefined window w1 (1 : 37)
+SELECT int_col, sum(float_col) OVER w1 FROM test
+ ^
+==
+
+SELECT sum(avg(int_col)) OVER w FROM test
+WINDOW w AS
+(PARTITION BY double_col
+ ORDER BY char_col)
+--
+ERROR: Aggregation of Aggregates are not allowed (1 : 12)
+SELECT sum(avg(int_col)) OVER w FROM test
+ ^