Functions Become Data: Higher-Order Lambda Functions for Database Systems

The invention of the relational model in 1970 laid the foundation for the enduring success of SQL as the data query language. Since then, support for user-defined functions has been considered an unnatural extension of relational algebra and a second-class citizen to SQL. SQL lambda expressions were introduced to allow users to customise otherwise hard-coded data mining operators, such as the distance function for k-Means clustering. However, database systems parse lambda expressions during semantic analysis, which does not allow functions as arguments. Let us break down the barrier between data and query language and let functions become first-class citizens in SQL. When functions become data, they can be stored, retrieved and executed within regular SQL queries. This proposal aims to be the logical next step for SQL lambda functions, integrating the lambda calculus into database systems by enabling higher-order logic and demonstrating its application to machine learning.

Model databases track the accuracy of models on pre-trained weights. The models are stored as executable code and extracted on deployment. Instead of extracting runnable code and data out of a database system, we propose higher-order SQL lambda functions for in-database execution. SQL lambda expressions have been introduced to let the user customise otherwise hard-coded data mining operators such as the distance function for k-means clustering. However, database systems parse lambda expressions during the semantic analysis, which does not allow for functions as arguments.

In this proposal, we envision database systems taking over the entire life cycle of a machine learning pipeline.
The goal is to store and retrieve models completely in SQL, a standardised declarative language, which we want to establish as the general-purpose language for machine learning. Thus we tune database systems for machine learning by providing higher-order lambda functions to be used as model functions. Further, we implement the required data types, matrices on specialised floating point numbers, natively into database systems and support hardware accelerators such as GPUs. Finally, we want to improve database optimisers for machine learning workloads.