UDF to SQL translation through compositional lazy inductive synthesis
Guoqiang Zhang, Yuanchao Xu, Xipeng Shen, Isil Dillig
Abstract
Many data processing systems allow SQL queries that call user-defined functions (UDFs) written in conventional programming languages. While such SQL extensions provide convenience and flexibility to users, queries involving UDFs are not as efficient as their pure SQL counterparts that invoke SQL's highly-optimized built-in functions. Motivated by this problem, we propose a new technique for translating SQL queries with UDFs to pure SQL expressions. Unlike prior work in this space, our method is not based on syntactic rewrite rules and can handle a much more general class of UDFs. At a high-level, our method is based on counterexample-guided inductive synthesis (CEGIS) but employs a novel compositional strategy that decomposes the synthesis task into simpler sub-problems. However, because there is no universal decomposition strategy that works for all UDFs, we propose a novel lazy inductive synthesis approach that generates a sequence of decompositions that correspond to increasingly harder inductive synthesis problems. Because most realistic UDF-to-SQL translation tasks are amenable to a fine-grained decomposition strategy, our lazy inductive synthesis method scales significantly better than traditional CEGIS.
We have implemented our proposed technique in a tool called CLIS for optimizing Spark SQL programs containing Scala UDFs. To evaluate CLIS, we manually study 100 randomly selected UDFs and find that 63 of them can be expressed in pure SQL. Our evaluation on these 63 UDFs shows that CLIS can automatically synthesize equivalent SQL expressions in 92% of the cases and that it can solve 2.4× more benchmarks compared to a baseline that does not use our compositional approach. We also show that CLIS yields an average speed-up of 3.5× for individual UDFs and 1.3× to 3.1× in terms of end-to-end application performance.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 39c88713-a8b8-4031-8eab-5bd7100c8de6Cited by top-tier papers8
- Data Extraction via Semantic Regular Expression SynthesisQiaochu Chen, Arko Banerjee, Çagatay Demiralp, Greg Durrett et al.OOPSLA 2023 · 24 citations
- Predicate Pushdown for Data Science PipelinesCong Yan, Yin Lin, Yeye HeSIGMOD 2023 · 15 citations
- The Key to Effective UDF Optimization: Before Inlining, First Perform OutliningSamuel Arch, Yuchen Liu, Todd C. Mowry, Jignesh M. Patel et al.VLDB 2025 · 8 citations
- Control-Flow Deobfuscation using Trace-Informed Compositional Program SynthesisBenjamin Mariano, Ziteng Wang, Shankara Pailoor, Christian S. Collberg et al.OOPSLA 2024 · 5 citations
- Automated Translation of Functional Big Data Queries to SQLGuoqiang Zhang, Benjamin Mariano, Xipeng Shen, Isil DilligOOPSLA 2023 · 5 citations
Builds on3
- Reconciling enumerative and deductive program synthesisKangjing Huang, Xiaokang Qiu, Peiyuan Shen, Yanjun WangPLDI 2020 · 46 citations
- Synthesizing JIT Compilers for In-Kernel DSLsJacob Van Geffen, Luke Nelson, Isil Dillig, Xi Wang et al.CAV 2020 · 27 citations
- Aggify: Lifting the Curse of Cursor Loops using Custom AggregatesSurabhi Gupta, Sanket Purandare, Karthik RamachandraSIGMOD 2020 · 22 citations
Related papers
- QURE: AI-Assisted and Automatically Verified UDF InliningTarique Siddiqui, Arnd Christian König, Jiashen Cao, Cong Yan et al.SIGMOD 2025 · 2 citations
- Functional-Style SQL UDFs With a Capital 'F'Christian Duta, Torsten GrustSIGMOD 2020 · 11 citations
- MONSOON: Multi-Step Optimization and Execution of Queries with Partially Obscured PredicatesSourav Sikdar, Chris JermaineSIGMOD 2020 · 6 citations
- One WITH RECURSIVE is Worth Many GOTOsDenis Hirn, Torsten GrustSIGMOD 2021 · 19 citations
- The UDFBench Benchmark for General-purpose UDF QueriesYannis Foufoulas, Theoni Palaiologou, Alkis SimitsisVLDB 2025
