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,
|
List *originalTargetEntryList,
|
||||||
QueryWindowClause *queryWindowClause,
|
QueryWindowClause *queryWindowClause,
|
||||||
QueryTargetList *queryTargetList);
|
QueryTargetList *queryTargetList);
|
||||||
static void ProcessWindowFunctionPullUpForWorkerQuery(MultiExtendedOp *originalOpNode,
|
static void ProcessWindowFunctionPullUpForWorkerQuery(List *windowClause,
|
||||||
QueryTargetList *queryTargetList);
|
QueryTargetList *queryTargetList);
|
||||||
static void ProcessLimitOrderByForWorkerQuery(OrderByLimitReference orderByLimitReference,
|
static void ProcessLimitOrderByForWorkerQuery(OrderByLimitReference orderByLimitReference,
|
||||||
Node *originalLimitCount, Node *limitOffset,
|
Node *originalLimitCount, Node *limitOffset,
|
||||||
|
@ -2247,15 +2247,23 @@ WorkerExtendedOpNode(MultiExtendedOp *originalOpNode,
|
||||||
&queryHavingQual, &queryTargetList,
|
&queryHavingQual, &queryTargetList,
|
||||||
&queryGroupClause);
|
&queryGroupClause);
|
||||||
|
|
||||||
if (extendedOpNodeProperties->onlyPushableWindowFunctions)
|
/*
|
||||||
|
* Planner optimizations may leave window clauses with hasWindowFuncs as false.
|
||||||
|
* Ignore window clauses in that case.
|
||||||
|
*/
|
||||||
|
if (extendedOpNodeProperties->hasWindowFuncs)
|
||||||
{
|
{
|
||||||
ProcessWindowFunctionsForWorkerQuery(originalWindowClause,
|
if (extendedOpNodeProperties->onlyPushableWindowFunctions)
|
||||||
originalTargetEntryList,
|
{
|
||||||
&queryWindowClause, &queryTargetList);
|
ProcessWindowFunctionsForWorkerQuery(originalWindowClause,
|
||||||
}
|
originalTargetEntryList,
|
||||||
else
|
&queryWindowClause, &queryTargetList);
|
||||||
{
|
}
|
||||||
ProcessWindowFunctionPullUpForWorkerQuery(originalOpNode, &queryTargetList);
|
else
|
||||||
|
{
|
||||||
|
ProcessWindowFunctionPullUpForWorkerQuery(originalWindowClause,
|
||||||
|
&queryTargetList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ShouldProcessDistinctOrderAndLimitForWorker(extendedOpNodeProperties,
|
if (ShouldProcessDistinctOrderAndLimitForWorker(extendedOpNodeProperties,
|
||||||
|
@ -2545,8 +2553,6 @@ ProcessWindowFunctionsForWorkerQuery(List *windowClauseList,
|
||||||
{
|
{
|
||||||
if (windowClauseList == NIL)
|
if (windowClauseList == NIL)
|
||||||
{
|
{
|
||||||
queryWindowClause->hasWindowFunctions = false;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2589,12 +2595,12 @@ ProcessWindowFunctionsForWorkerQuery(List *windowClauseList,
|
||||||
|
|
||||||
/* ProcessWindowFunctionPullUpForWorkerQuery pulls up inputs for window functions */
|
/* ProcessWindowFunctionPullUpForWorkerQuery pulls up inputs for window functions */
|
||||||
static void
|
static void
|
||||||
ProcessWindowFunctionPullUpForWorkerQuery(MultiExtendedOp *originalOpNode,
|
ProcessWindowFunctionPullUpForWorkerQuery(List *windowClause,
|
||||||
QueryTargetList *queryTargetList)
|
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;
|
Expr *newExpression = NULL;
|
||||||
foreach_ptr(newExpression, columnList)
|
foreach_ptr(newExpression, columnList)
|
||||||
|
|
|
@ -1610,6 +1610,8 @@ BuildSubqueryJobQuery(MultiNode *multiNode)
|
||||||
jobQuery->windowClause = windowClause;
|
jobQuery->windowClause = windowClause;
|
||||||
jobQuery->hasSubLinks = checkExprHasSubLink((Node *) jobQuery);
|
jobQuery->hasSubLinks = checkExprHasSubLink((Node *) jobQuery);
|
||||||
|
|
||||||
|
Assert(jobQuery->hasWindowFuncs == contain_window_function((Node *) jobQuery));
|
||||||
|
|
||||||
return jobQuery;
|
return jobQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1566,3 +1566,11 @@ GROUP BY 1 ORDER BY 1;
|
||||||
5 | {675,675,816,816,987,987,1104,1104,1104}
|
5 | {675,675,816,816,987,987,1104,1104,1104}
|
||||||
(6 rows)
|
(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
|
JOIN users_ref_test_table uref ON uref.id = events_table.user_id) sq
|
||||||
GROUP BY 1 ORDER BY 1;
|
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