Python UDF data types
Python UDFs can use any standard Amazon Redshift data type for the input arguments and the function's return value. In addition to the standard data types, UDFs support the data type ANYELEMENT, which Amazon Redshift automatically converts to a standard data type based on the arguments supplied at runtime. Scalar UDFs can return a data type of ANYELEMENT. For more information, see ANYELEMENT data type.
During execution, Amazon Redshift converts the arguments from Amazon Redshift data types to Python data types for processing. It then converts the return value from the Python data type to the corresponding Amazon Redshift data type. For more information about Amazon Redshift data types, see Data types.
The following table maps Amazon Redshift data types to Python data types.
Amazon Redshift data type | Python data type |
---|---|
smallint integer bigint short long |
int |
decimal or numeric |
decimal |
double real |
float |
boolean |
bool |
char varchar |
string |
timestamp |
datetime |