Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] merge command when insert value does not have source distributed column #7620

Merged
merged 12 commits into from
Jun 15, 2024
28 changes: 20 additions & 8 deletions src/backend/distributed/planner/merge_planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,6 @@
return distributedPlan;
}

Var *insertVar =
FetchAndValidateInsertVarIfExists(targetRelationId, originalQuery);
if (insertVar &&
!IsDistributionColumnInMergeSource((Expr *) insertVar, originalQuery, true))
{
ereport(ERROR, (errmsg("MERGE INSERT must use the source table "
"distribution column value")));
}

Job *job = RouterJob(originalQuery, plannerRestrictionContext,
&distributedPlan->planningError);
Expand Down Expand Up @@ -1124,6 +1116,26 @@
"repartitioning")));
return deferredError;
}


/*
* If execution has reached this point, it indicates that the query can be delegated to the worker.
* However, before proceeding with this delegation, we need to confirm that the user is utilizing
* the distribution column of the source table in the Insert variable.
* If this is not the case, we should refrain from pushing down the query.
paragikjain marked this conversation as resolved.
Show resolved Hide resolved
*/

Var *insertVar =
FetchAndValidateInsertVarIfExists(targetRelationId, query);
if (insertVar &&
!IsDistributionColumnInMergeSource((Expr *) insertVar, query, true))
{
ereport(DEBUG1, (errmsg(

Check warning on line 1133 in src/backend/distributed/planner/merge_planner.c

View check run for this annotation

Codecov / codecov/patch

src/backend/distributed/planner/merge_planner.c#L1133

Added line #L1133 was not covered by tests
paragikjain marked this conversation as resolved.
Show resolved Hide resolved
"MERGE INSERT must use the source table distribution column value, try repartitioning")));
return DeferredError(ERRCODE_FEATURE_NOT_SUPPORTED,

Check warning on line 1135 in src/backend/distributed/planner/merge_planner.c

View check run for this annotation

Codecov / codecov/patch

src/backend/distributed/planner/merge_planner.c#L1135

Added line #L1135 was not covered by tests
"MERGE INSERT must use the source table "
"distribution column value", NULL, NULL);
}
return NULL;
}

Expand Down
Loading
Loading