A language-agnostic query engine could be implemented by following a canonical compiler design approach, i.e., implementing a common front-end query language (e.g., SQL), a common optimizer (e.g., a query planner) and language-specific backends for each target language. However, such an approach would require a lot of engineering efforts, since many conceptually similar operations need to be implemented in any backend. Moreover, integrating new query operators would require extending all language-specific backends.
The GraalVM project and the Truffle framework, in particular their interoperability libraries, offer a great opportunity for addressing the urgent need of LINQ frameworks on dynamic languages without incurring in the penalties mentioned above. In particular, query operators can be implemented with Truffle nodes, exploiting the automatic partial evaluation offered by the Graal compiler for generating efficient machine code for a given query. Moreover, leveraging the Truffle interoperability libraries, there is no need to replicate the implementation of similar operations in multiple backends, since entities of languages implemented with Truffle, e.g., objects and functions, can be accessed through interoperability libraries.
 Filippo Schiavio, Daniele Bonetta, Walter Binder: Language-Agnostic Integrated Queries in a Managed Polyglot Runtime. Proc. VLDB Endow. 14(8): 1414-1426 (2021) [pdf][video][slides]
1 M. Raasveldt, and H. Mühleisen. “Data Management for Data Science-Towards Embedded Analytics”. CIDR 2020
2 A. Shaikhha, M. Dashti, and C. Koch. “Push versus Pull-based Loop Fusion in Query Engines”. Journal of Functional Programming 2018.