mirror of https://github.com/citusdata/citus.git
Merge pull request #3757 from citusdata/fix-window-function-assertion-failure
Avoid setting hasWindowFuncs true after window functions have been optimized out of querypull/3775/head
commit
79f6f3c02c
|
@ -246,7 +246,7 @@ static void ProcessWindowFunctionsForWorkerQuery(List *windowClauseList,
|
|||
List *originalTargetEntryList,
|
||||
QueryWindowClause *queryWindowClause,
|
||||
QueryTargetList *queryTargetList);
|
||||
static void ProcessWindowFunctionPullUpForWorkerQuery(MultiExtendedOp *originalOpNode,
|
||||
static void ProcessWindowFunctionPullUpForWorkerQuery(List *windowClause,
|
||||
QueryTargetList *queryTargetList);
|
||||
static void ProcessLimitOrderByForWorkerQuery(OrderByLimitReference orderByLimitReference,
|
||||
Node *originalLimitCount, Node *limitOffset,
|
||||
|
@ -2247,6 +2247,12 @@ WorkerExtendedOpNode(MultiExtendedOp *originalOpNode,
|
|||
&queryHavingQual, &queryTargetList,
|
||||
&queryGroupClause);
|
||||
|
||||
/*
|
||||
* Planner optimizations may leave window clauses with hasWindowFuncs as false.
|
||||
* Ignore window clauses in that case.
|
||||
*/
|
||||
if (extendedOpNodeProperties->hasWindowFuncs)
|
||||
{
|
||||
if (extendedOpNodeProperties->onlyPushableWindowFunctions)
|
||||
{
|
||||
ProcessWindowFunctionsForWorkerQuery(originalWindowClause,
|
||||
|
@ -2255,7 +2261,9 @@ WorkerExtendedOpNode(MultiExtendedOp *originalOpNode,
|
|||
}
|
||||
else
|
||||
{
|
||||
ProcessWindowFunctionPullUpForWorkerQuery(originalOpNode, &queryTargetList);
|
||||
ProcessWindowFunctionPullUpForWorkerQuery(originalWindowClause,
|
||||
&queryTargetList);
|
||||
}
|
||||
}
|
||||
|
||||
if (ShouldProcessDistinctOrderAndLimitForWorker(extendedOpNodeProperties,
|
||||
|
@ -2545,8 +2553,6 @@ ProcessWindowFunctionsForWorkerQuery(List *windowClauseList,
|
|||
{
|
||||
if (windowClauseList == NIL)
|
||||
{
|
||||
queryWindowClause->hasWindowFunctions = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2589,12 +2595,12 @@ ProcessWindowFunctionsForWorkerQuery(List *windowClauseList,
|
|||
|
||||
/* ProcessWindowFunctionPullUpForWorkerQuery pulls up inputs for window functions */
|
||||
static void
|
||||
ProcessWindowFunctionPullUpForWorkerQuery(MultiExtendedOp *originalOpNode,
|
||||
ProcessWindowFunctionPullUpForWorkerQuery(List *windowClause,
|
||||
QueryTargetList *queryTargetList)
|
||||
{
|
||||
if (originalOpNode->windowClause != NIL)
|
||||
if (windowClause != NIL)
|
||||
{
|
||||
List *columnList = pull_var_clause_default((Node *) originalOpNode->windowClause);
|
||||
List *columnList = pull_var_clause_default((Node *) windowClause);
|
||||
|
||||
Expr *newExpression = NULL;
|
||||
foreach_ptr(newExpression, columnList)
|
||||
|
|
|
@ -1610,6 +1610,8 @@ BuildSubqueryJobQuery(MultiNode *multiNode)
|
|||
jobQuery->windowClause = windowClause;
|
||||
jobQuery->hasSubLinks = checkExprHasSubLink((Node *) jobQuery);
|
||||
|
||||
Assert(jobQuery->hasWindowFuncs == contain_window_function((Node *) jobQuery));
|
||||
|
||||
return jobQuery;
|
||||
}
|
||||
|
||||
|
|
|
@ -1566,3 +1566,11 @@ GROUP BY 1 ORDER BY 1;
|
|||
5 | {675,675,816,816,987,987,1104,1104,1104}
|
||||
(6 rows)
|
||||
|
||||
-- https://github.com/citusdata/citus/issues/3754
|
||||
select null = sum(null::int2) over ()
|
||||
from public.users_table as ut limit 1;
|
||||
?column?
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
|
|
@ -612,3 +612,7 @@ FROM events_table
|
|||
JOIN users_ref_test_table uref ON uref.id = events_table.user_id) sq
|
||||
GROUP BY 1 ORDER BY 1;
|
||||
|
||||
-- https://github.com/citusdata/citus/issues/3754
|
||||
select null = sum(null::int2) over ()
|
||||
from public.users_table as ut limit 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue