Changeset: 28b1ec5883ad for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/28b1ec5883ad Added Files: sql/test/BugTracker-2024/Tests/7514-wrong-window-function.test Modified Files: sql/server/rel_select.c sql/test/BugTracker-2024/Tests/All Branch: default Log Message:
solved issue #7514, handle window function with more than 2 arguments diffs (60 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 @@ -4744,6 +4744,23 @@ rel_rankop(sql_query *query, sql_rel **r char *uaname = SA_NEW_ARRAY(sql->ta, char, strlen(aname) + 1); return sql_error(sql, 02, SQLSTATE(42000) "%s: window functions cannot be nested", toUpperCopy(uaname, aname)); } + if (window_function->token == SQL_UNOP || window_function->token == SQL_OP) { + window_function->token = SQL_NOP; + dn->next->next->data.lval = dlist_append_symbol(sql->sa, dlist_create( sql->sa ), dn->next->next->data.sym); /* make a list */ + } + if (window_function->token == SQL_BINOP) { + window_function->token = SQL_NOP; + dn->next->next->data.lval = dlist_append_symbol(sql->sa, dlist_append_symbol(sql->sa, dlist_create( sql->sa ), dn->next->next->data.sym), dn->next->next->next->data.sym); /* make a list */ + dn->next->next->next = dn->next->next->next->next; /* skip second arg */ + } + if (window_function->token == SQL_AGGR) + dn->next->next->data.lval = dlist_append_symbol(sql->sa, dlist_create( sql->sa ), dn->next->next->data.sym); /* make a list */ + if (window_function->token == SQL_NOP) + window_function->token = SQL_AGGR; + if (window_function->token != SQL_RANK && window_function->token != SQL_AGGR) { + char *uaname = SA_NEW_ARRAY(sql->ta, char, strlen(aname) + 1); + return sql_error(sql, 02, SQLSTATE(42000) "SELECT: window function '%s' unknown", toUpperCopy(uaname, aname)); + } /* window operations are only allowed in the projection */ if (!is_sql_sel(f)) @@ -4814,7 +4831,7 @@ rel_rankop(sql_query *query, sql_rel **r } } else { /* aggregation function call */ distinct = dn->next->data.i_val; - for (dargs = dn->next->next ; dargs && dargs->data.sym ; dargs = dargs->next) { + for (dargs = dn->next->next->data.lval->h ; dargs && dargs->data.sym ; dargs = dargs->next) { exp_kind ek = {type_value, card_column, FALSE}; sql_subtype *empty = sql_bind_localtype("void"), *bte = sql_bind_localtype("bte"); diff --git a/sql/test/BugTracker-2024/Tests/7514-wrong-window-function.test b/sql/test/BugTracker-2024/Tests/7514-wrong-window-function.test new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2024/Tests/7514-wrong-window-function.test @@ -0,0 +1,11 @@ +statement error SELECT: no such window function 'wrong_function'(tinyint, tinyint, tinyint) +select + wrong_function(col1, col2, col3) over w +from + (select 0 as col1, 1 as col2, 2 as col3) t window w as (partition by col1) + +statement error SELECT: identifier 'wrong_column' unknown +select + wrong_function(col1, col2, wrong_column) over w +from + (select 0 as col1, 1 as col2, 2 as col3) t window w as (partition by col1) diff --git a/sql/test/BugTracker-2024/Tests/All b/sql/test/BugTracker-2024/Tests/All --- a/sql/test/BugTracker-2024/Tests/All +++ b/sql/test/BugTracker-2024/Tests/All @@ -58,3 +58,4 @@ field-arg-error-Bug-7506 7511-password-hash-missing-error 7512-concurrent-globaltmp-instantiate-crash 7513-uri-authority-parse-issue +7514-wrong-window-function _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org