Update comments, checks

onur-leftjoin_push-improvements
eaydingol 2025-08-13 13:03:12 +03:00
parent 13405e7871
commit a964d45323
5 changed files with 12 additions and 14 deletions

View File

@ -222,8 +222,8 @@ DefineQualsForShardInterval(RelationShard *relationShard, int attnum, int rtinde
/* /*
* Add constraints for the relation identified by rtindex, specifically on its column at attnum. * Add constraints for the relation identified by rtindex, specifically on its column at attnum.
* Create a Var node representing this column, which will be used to compare against the partition * Create a Var node representing this column, which will be used to compare against the bounds
* column for shard interval qualification. * from the partition column of shard interval.
*/ */
Var *outerTablePartitionColumnVar = makeVar( Var *outerTablePartitionColumnVar = makeVar(
@ -371,6 +371,7 @@ UpdateWhereClauseForOuterJoinWalker(Node *node, List *relationShardList)
* outerRtIndex : RT index whose column we will constrain, * outerRtIndex : RT index whose column we will constrain,
* outerRte / innerRte, * outerRte / innerRte,
* attnum : attribute number (partition column) on outer side. * attnum : attribute number (partition column) on outer side.
* This is compared to partition column of innerRte.
* 3. Find the RelationShard for the inner distributed table (innerRte->relid) * 3. Find the RelationShard for the inner distributed table (innerRte->relid)
* in relationShardList; skip if absent (no fixed shard chosen). * in relationShardList; skip if absent (no fixed shard chosen).
* 4. Build the shard qualification with DefineQualsForShardInterval(): * 4. Build the shard qualification with DefineQualsForShardInterval():
@ -385,7 +386,7 @@ UpdateWhereClauseForOuterJoinWalker(Node *node, List *relationShardList)
void void
UpdateWhereClauseForOuterJoin(Query *query, List *relationShardList) UpdateWhereClauseForOuterJoin(Query *query, List *relationShardList)
{ {
if (query == NULL || query->jointree == NULL || query->jointree->fromlist == NIL) if (query == NULL)
{ {
return; return;
} }

View File

@ -2357,8 +2357,6 @@ QueryPushdownSqlTaskList(Query *query, uint64 jobId,
* *
* The function also sets outerPartHasDistributedTable if the outer part * The function also sets outerPartHasDistributedTable if the outer part
* of the corresponding join has a distributed table. * of the corresponding join has a distributed table.
*
* The function returns true only if all three conditions above hold true.
*/ */
static bool static bool
IsInnerTableOfOuterJoin(RelationRestriction *relationRestriction, IsInnerTableOfOuterJoin(RelationRestriction *relationRestriction,
@ -2598,17 +2596,11 @@ QueryPushdownTaskCreate(Query *originalQuery, int shardIndex,
*/ */
UpdateRelationToShardNames((Node *) taskQuery, relationShardList); UpdateRelationToShardNames((Node *) taskQuery, relationShardList);
if (updateQualsForOuterJoin)
{
UpdateWhereClauseForOuterJoinWalker((Node *) taskQuery, relationShardList);
}
/* /*
* Ands are made implicit during shard pruning, as predicate comparison and * Ands are made implicit during shard pruning, as predicate comparison and
* refutation depend on it being so. We need to make them explicit again so * refutation depend on it being so. We need to make them explicit again so
* that the query string is generated as (...) AND (...) as opposed to * that the query string is generated as (...) AND (...) as opposed to
* (...), (...). * (...), (...).
* TODO: do we need to run this before adding quals?
*/ */
if (taskQuery->jointree->quals != NULL && IsA(taskQuery->jointree->quals, List)) if (taskQuery->jointree->quals != NULL && IsA(taskQuery->jointree->quals, List))
{ {
@ -2616,6 +2608,12 @@ QueryPushdownTaskCreate(Query *originalQuery, int shardIndex,
(List *) taskQuery->jointree->quals); (List *) taskQuery->jointree->quals);
} }
if (updateQualsForOuterJoin)
{
UpdateWhereClauseForOuterJoinWalker((Node *) taskQuery, relationShardList);
}
Task *subqueryTask = CreateBasicTask(jobId, taskId, taskType, NULL); Task *subqueryTask = CreateBasicTask(jobId, taskId, taskType, NULL);
if ((taskType == MODIFY_TASK && !modifyRequiresCoordinatorEvaluation) || if ((taskType == MODIFY_TASK && !modifyRequiresCoordinatorEvaluation) ||

View File

@ -2334,7 +2334,6 @@ RegisterCitusConfigVariables(void)
GUC_UNIT_BYTE | GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE, GUC_UNIT_BYTE | GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE,
NULL, NULL, NULL); NULL, NULL, NULL);
DefineCustomIntVariable( DefineCustomIntVariable(
"citus.recover_2pc_interval", "citus.recover_2pc_interval",
gettext_noop("Sets the time to wait between recovering 2PCs."), gettext_noop("Sets the time to wait between recovering 2PCs."),

View File

@ -306,7 +306,7 @@ ORDER BY 1, 2;
5 | 5 5 | 5
(2 rows) (2 rows)
-- reference table LEFT JOIN distributed table in WHERE is ok -- reference table LEFT JOIN distributed table in WHERE is still not ok
SELECT user_id, value_2 FROM users_table WHERE SELECT user_id, value_2 FROM users_table WHERE
value_1 > 1 AND value_1 < 3 value_1 > 1 AND value_1 < 3
AND value_2 >= 5 AND value_2 >= 5

View File

@ -260,7 +260,7 @@ SELECT user_id, value_2 FROM users_table WHERE
) )
ORDER BY 1, 2; ORDER BY 1, 2;
-- reference table LEFT JOIN distributed table in WHERE is ok -- reference table LEFT JOIN distributed table in WHERE is still not ok
SELECT user_id, value_2 FROM users_table WHERE SELECT user_id, value_2 FROM users_table WHERE
value_1 > 1 AND value_1 < 3 value_1 > 1 AND value_1 < 3
AND value_2 >= 5 AND value_2 >= 5