Another Way to Implement Complex Computations: Functional-Style SQL UDF

Christian Duta

Proceedings of the Workshop on Human-In-the-Loop Data Analytics (HILDA 2022), collocated with SIGMOD 2022, Philadelphia, PA, USA, June 2022. To be published.


Whenever data-intensive computation gets so complex that it requires the use of iteration or recursion, SQL developers turn towards recursive common table expressions (CTEs). We present the results of a user study that shows how developers struggle with the unusual fixpoint semantics and awkward monolithic syntactic structure of CTEs. The study suggests that recursive user-defined functions (UDFs)—written in a style much like regular functional programs—are less prone to errors, significantly more readable, and can be authored more quickly. Since such recursive UDFs can be automatically compiled into efficiently executable CTEs, we put functional-style UDFs forward as another promising pillar to express complex computation close to the data.