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

Adding the ability to create a non-distributed table (can be used for postgres extensions) #645

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/backend/parser/gram.y
Original file line number Diff line number Diff line change
Expand Up @@ -6046,6 +6046,15 @@ DistributedBy: DISTRIBUTED BY '(' distributed_by_list ')'
distributedBy->keyCols = NIL;
$$ = (Node *)distributedBy;
}
| DISTRIBUTED LOCAL
{
DistributedBy *distributedBy = makeNode(DistributedBy);
distributedBy->ptype = POLICYTYPE_LOCAL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we did choose POLICYTYPE_LOCAL Instead of POLICYTYPE_ENRTY, because getPolicyForDistributedBy explicitly forbits creating relation with POLICYTYPE_ENRTY policy. We are unaware of reason however.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible we keep distributeBy as NULL like pg_class? So that planner could work properly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will think about that

distributedBy->numsegments = -1;
distributedBy->keyCols = NIL;
$$ = (Node *)distributedBy;

}
;

OptDistributedBy: DistributedBy
Expand Down
6 changes: 6 additions & 0 deletions src/backend/parser/parse_utilcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2417,6 +2417,9 @@ transformDistributedBy(ParseState *pstate,
ListCell *lc;
int numsegments;

if(distributedBy->ptype == POLICYTYPE_LOCAL){
return distributedBy;
}
/*
* utility mode creates can't have a policy. Only the QD can have policies
*/
Expand Down Expand Up @@ -3134,6 +3137,9 @@ getPolicyForDistributedBy(DistributedBy *distributedBy, TupleDesc tupdesc)

case POLICYTYPE_REPLICATED:
return createReplicatedGpPolicy(distributedBy->numsegments);

case POLICYTYPE_LOCAL:
return NULL;
}
elog(ERROR, "unrecognized policy type %d", distributedBy->ptype);
return NULL;
Expand Down
3 changes: 2 additions & 1 deletion src/include/catalog/gp_distribution_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ typedef enum GpPolicyType
{
POLICYTYPE_PARTITIONED, /* Tuples partitioned onto segment database. */
POLICYTYPE_ENTRY, /* Tuples stored on entry database. */
POLICYTYPE_REPLICATED /* Tuples stored a copy on all segment database. */
POLICYTYPE_REPLICATED, /* Tuples stored a copy on all segment database. */
POLICYTYPE_LOCAL /* Tuples stored on coordinator */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the new policy type, is it any different from POLICYTYPE_ENTRY?

} GpPolicyType;

/*
Expand Down