Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Replace gp_segment_id with UDF
Browse files Browse the repository at this point in the history
Since commit 6467882, access to gp_segment_id is explicitly disabled.
(Before the PR they can be accessed just "by accident") This is because
they are too limited and only valid for "regular tables".

This patch replaces gp_segment_id with UDF gp_execution_segment().
The latter can be applied on not only regular tables, but also queries.
Therefore, it is more general than gp_segment_id
  • Loading branch information
Xuebin Su committed Sep 1, 2023
1 parent 4118bff commit 62aa68b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions doc/source/notebooks/abalone.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -417,14 +417,15 @@
}
],
"source": [
"# SELECT gp_segment_id, COUNT(*)\n",
"# SELECT gp_execution_segment() AS gp_segment_id, COUNT(*)\n",
"# FROM abalone\n",
"# GROUP BY 1\n",
"# ORDER BY gp_segment_id;\n",
"# GROUP BY 1;\n",
"\n",
"import greenplumpython.builtins.functions as F\n",
"\n",
"abalone.group_by(\"gp_segment_id\").apply(lambda _: F.count())"
"abalone.assign(gp_segment_id=lambda _: gp.function(\"gp_execution_segment\")()).group_by(\n",
" \"gp_segment_id\"\n",
").apply(lambda _: F.count())"
]
},
{
Expand Down

0 comments on commit 62aa68b

Please sign in to comment.