Abstract: In an example method, a computer system receives a query for data stored in a relational database management system. The query includes one or more first functions of a first programming language, and one or more second functions specifying computer code of a second programming language different from the first programming language. The computer system generates a logical query plan based on the query, including one or more first logical nodes corresponding to the one or more first functions, and one or more second logical nodes corresponding to the one or more second functions in an interconnected logical tree. The computer system generates a physical execution plan based on the logical query plan, and executes the physical execution plan to retrieve the data stored in the relational database management system.