Column Type#

The Column type provides the structure and organization for storing and retrieving columnar data within HeavyDB.

Basic usage#

from test_column_power of rbc/tests/heavydb/test_howtos.py#
 1import numpy as np
 2
 3@heavydb('int32(TableFunctionManager, Column<T>, T, OutputColumn<T>)',
 4         T=['int64'])
 5def udtf_power(mgr, inp, exp, out):
 6    size = len(inp)
 7    mgr.set_output_row_size(size)
 8    for i in range(size):
 9        out[i] = np.power(inp[i], exp)
10    return size
Example SQL Query
from test_column of rbc/tests/heavydb/test_howtos.py#
1query = '''
2    SELECT * FROM TABLE(udtf_power(
3        cursor(SELECT * FROM TABLE(generate_series(1, 5, 1))),
4        3
5    ))
6'''
7_, r = heavydb.sql_execute(query)
8assert list(r) == [(1,), (8,), (27,), (64,), (125,)]