The Greenplum Database (hereinafter referred to as the GP database) supports custom functions, and the following describes the custom simple functions written by Python. The clustering function is more complex and self-sensing is not suitable for the GP database.
The Python custom function describes what GP can do as long as Python can handle the row-level data.
Example: Python returns multiple rows for JSON processing.
Create or Replace function public.json_parse (data text) returns Setof text
As $$
Import JSON
Try
Mydata=json.loads (data)
Except
return [' Parse error ']
Returndata=[]
Try
For people in mydata[' a ']:
Returndata.append (people[' B ')
Except
return [' 223 ']
Return Returndata
$$ LANGUAGE Plpythonu;
This article is from the "11821925" blog, please be sure to keep this source http://11831925.blog.51cto.com/11821925/1836434
Greenplum Database Python custom functions