Skip to content

Commit

Permalink
Enable window functions
Browse files Browse the repository at this point in the history
  • Loading branch information
def- committed Oct 13, 2023
1 parent f8c2894 commit 8ebbbb3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ using impedance::matched;
shared_ptr<value_expr> value_expr::factory(prod *p, sqltype *type_constraint, bool can_return_set)
{
try {
// ERROR: aggregate window functions not yet supported
//if (1 == d20() && p->level < d6() && window_function::allowed(p))
// return make_shared<window_function>(p, type_constraint);
if (1 == d20() && p->level < d6() && window_function::allowed(p))
return make_shared<window_function>(p, type_constraint);
if (1 == d42() && p->level < d6() && type_constraint && type_constraint->name.rfind("list", 0) != 0 && type_constraint->name.rfind("map", 0) != 0 && type_constraint->name.rfind("record", 0) != 0 && type_constraint->name.rfind("any", 0) != 0)
return make_shared<coalesce>(p, type_constraint);
else if (1 == d42() && p->level < d6() && type_constraint && type_constraint->name.rfind("list", 0) != 0 && type_constraint->name.rfind("map", 0) != 0 && type_constraint->name.rfind("record", 0) != 0 && type_constraint->name.rfind("any", 0) != 0)
Expand Down Expand Up @@ -557,7 +556,7 @@ window_function::window_function(prod *p, sqltype *type_constraint)
: value_expr(p)
{
match();
aggregate = make_shared<funcall>(this, type_constraint, true);
aggregate = make_shared<funcall>(this, type_constraint, true, true);
type = aggregate->type;
partition_by.push_back(make_shared<column_reference>(this));
while(d6() > 4)
Expand Down
2 changes: 1 addition & 1 deletion grammar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ void explain_stmt::out(std::ostream &out) {
if (for_supported) {
out << "for ";
}
if(with_supported && d6() > 3) {
if(with_supported && d6() == 1) {
out << "create materialized view mv as ";
}
out << *q;
Expand Down
3 changes: 2 additions & 1 deletion postgres.cc
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,9 @@ schema_pqxx::schema_pqxx(std::string &conninfo, bool no_catalog) : c(conninfo)
"ON mz_functions.return_type_id = ret_type.id "
"WHERE mz_functions.name not in ('pg_event_trigger_table_rewrite_reason', 'percentile_cont', 'dense_rank', 'cume_dist', 'rank', 'test_rank', 'percent_rank', 'percentile_disc', 'mode', 'test_percentile_disc') "
"AND mz_functions.name !~ '^ri_fkey_' "
"AND NOT (mz_functions.name in ('sum', 'avg') AND ret_type.oid = 1186) " // https://github.com/MaterializeInc/materialize/issues/18043
"AND NOT (mz_functions.name in ('sum', 'avg', 'avg_internal_v1') AND ret_type.oid = 1186) " // https://github.com/MaterializeInc/materialize/issues/18043
"AND mz_functions.name <> 'array_agg' " // https://github.com/MaterializeInc/materialize/issues/18044
"AND (mz_functions.name <> 'string_agg' AND ret_type.oid = 17) " // string_agg on BYTEA not yet supported
"AND NOT mz_functions.name in ('mz_all', 'mz_any') " // https://github.com/MaterializeInc/materialize/issues/18057
"AND " + procedure_is_aggregate + " AND NOT " + procedure_is_window);
for (auto row : r) {
Expand Down

0 comments on commit 8ebbbb3

Please sign in to comment.