Calcite integration
For readers who are curious about how the integration with Calcite is implemented, we cover the relevant classes briefly in this section.
Calcite is a rather substantial project with a large and complex API, so in this short section we will merely touch upon its capabilities; the reader is encouraged to review the Calcite docs and source code to gain deeper insights into the API.
Here is a (very) high-level summary of how things work. After the desired custom functions and pseudo-tables are registered with the SQLExecEnvironment
class (typically, in the populateDAG()
method), the executeSQL()
method is invoked to kick off all the hard work of parsing the SQL query, creating the necessary operators and adding them to the DAG, generating Java classes for the columns, wrapping them in a JAR file and finally adding the JAR file to the appropriate DAG attribute, so that they can be found and used at runtime. The bulk of the work starts with the RelNodeVisitor.traverse()
call...