Changeset: 8edc8c29c063 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/8edc8c29c063 Modified Files: sql/server/rel_select.c sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test sql/test/analytics/Tests/analytics00.test Branch: Sep2022 Log Message:
Window functions cannot be nested I have the setup done, so I can do more stuff now. diffs (66 lines): diff --git a/sql/server/rel_select.c b/sql/server/rel_select.c --- a/sql/server/rel_select.c +++ b/sql/server/rel_select.c @@ -4498,13 +4498,15 @@ rel_order_by_column_exp(sql_query *query if (needs_distinct) return sql_error(sql, 02, SQLSTATE(42000) "SELECT: with DISTINCT ORDER BY expressions must appear in select list"); e = rel_project_add_exp(sql, p, e); - for (node *n = p->exps->h ; n ; n = n->next) { - sql_exp *ee = n->data; - - if (ee->card > r->card) { - if (exp_name(ee) && !has_label(ee)) - return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s' in query results without an aggregate function", exp_name(ee)); - return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column in query results without an aggregate function"); + if (r) { + for (node *n = p->exps->h ; n ; n = n->next) { + sql_exp *ee = n->data; + + if (ee->card > r->card) { + if (exp_name(ee) && !has_label(ee)) + return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column '%s' in query results without an aggregate function", exp_name(ee)); + return sql_error(sql, ERR_GROUPBY, SQLSTATE(42000) "SELECT: cannot use non GROUP BY column in query results without an aggregate function"); + } } } } @@ -4613,7 +4615,7 @@ rel_order_by(sql_query *query, sql_rel * sql->session->status = 0; sql->errstr[0] = '\0'; - e = rel_order_by_column_exp(query, &rel, col, needs_distinct, sql_sel | sql_orderby | (f & sql_group_totals)); + e = rel_order_by_column_exp(query, &rel, col, needs_distinct, sql_sel | sql_orderby | (f & sql_group_totals) | (f & sql_window)); } if (!e) return NULL; diff --git a/sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test b/sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test --- a/sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test +++ b/sql/test/BugTracker-2022/Tests/single_row_in_rel_order_by_column.Bug-7306.test @@ -18,13 +18,9 @@ SELECT avg(42) over (order by 2); ---- 42.000 -query I +statement error 42000!ROW_NUMBER: window functions cannot be nested SELECT count(*) over (order by row_number() over ()); ----- -1 -query R +statement error 42000!ROW_NUMBER: window functions cannot be nested SELECT avg(42) over (order by row_number() over ()); ----- -42.000 diff --git a/sql/test/analytics/Tests/analytics00.test b/sql/test/analytics/Tests/analytics00.test --- a/sql/test/analytics/Tests/analytics00.test +++ b/sql/test/analytics/Tests/analytics00.test @@ -1922,3 +1922,8 @@ 2 statement ok rollback +statement error 42000!ROW_NUMBER: window functions cannot be nested +SELECT avg(42) over (order by row_number() over ()) + +statement error 42000!ROW_NUMBER: window functions cannot be nested +SELECT avg(42) over (partition by row_number() over ()) _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org