Sparse SQL Reference

Reference
SQL
Author

Kian Ghodoussi

Published

March 6, 2025

Overview

Name Description
sparse_list_extract(position, inds, vals) Returns the value of a sparse array at the requested position (1 Indexed)
sparse_list_select(positions, inds, vals) Returns the values of a sparse array at the requested position (1 Indexed)
dense_x_sparse_dot_product(dense_arr, inds, vals) Returns the dot product between a dense array and a sparse array
sparse_to_dense(K, inds, vals) Constructs a dense array of size K from sparse inds + vals
agg_array_sum(arrs) Sum a list of arrays of size K. Returns a single array of size K

Examples

sparse_list_extract(position, inds, vals)

Description Returns the value of a sparse array at the requested position (1 Indexed)
Example sparse_list_extract(4, [1,4,6], [.1, .2, .3])
Result .2

sparse_list_select(position, inds, vals)

Description Returns the value of a sparse array at the requested position (1 Indexed)
Example sparse_list_select([4, 6, 12], [1,4,6], [.1, .2, .3])
Result [.2, .3, 0]

dense_x_sparse_dot_product(dense_arr, inds, vals)

Description Returns the dot product between a dense array and a sparse array
Example dense_x_sparse_dot_product([0, 0, 1, 0], [1, 3], [10, 20])
Result 20

sparse_to_dense(K, inds, vals)

Description Constructs a dense array of size K from sparse inds + vals
Example sparse_to_dense(5, [1, 3], [10, 20])
Result [10, 0, 20, 0, 0]

agg_array_sum(arrs)

Description Sum a list of arrays of size K. Returns a single array of size K
Example agg_array_sum([[1,2,3], [4,5,6]])
Result [5, 7, 9]