User Defined Functions (UDFs)#
Basics#
UDFs are functions that operate at row-level. That is, they receive as input a single row at a time.
1@heavydb('int64(int64)')
2def incr(a):
3 return a + 1
Example SQL Query
1_, result = heavydb.sql_execute('SELECT incr(3)')
2assert list(result) == [(4,)]
Multiple signatures#
Defining UDFs with multiple signatures
1@heavydb('int64(int64, int64)', 'float64(float64, float64)')
2def multiply(a, b):
3 return a * b
Example SQL Query
1_, result = heavydb.sql_execute('SELECT multiply(3.0, 2.0)')
2assert list(result) == [(6.0,)]