Virtual schemas allow virtually accessing external data sources. Virtual Schemas require Adapter Scripts, that can be implemented in Java and Python.
Adapter scripts can now also be written in Lua. Such adapters have a much smaller runtime overhead and can execute local SELECT queries transaction-safe.
The virtual schema callback function has the following signature in Lua:
The Lua CJSON library can be used for JSON handling, see
During the execution of the statements CREATE VIRTUAL SCHEMA, ALTER VIRTUAL SCHEMA, and DROP VIRTUAL SCHEMA (i.e., during the Virtual Schema API request types "createVirtualSchema", "refresh", "setProperties", and "dropVirtualSchema") the Lua adapter script can execute SQL statements. The statements run locally in the same transaction and session as the virtual schema statements. The API for this is similar to the query and pquery functions, but instead there are two new functions which are only available in Lua adapter scripts: exa.query_no_preprocessing and exa.pquery_no_preprocessing.
The following restrictions are enforced for these functions in Lua adapter scripts:
- The queries always run with the privileges of the virtual schema owner.
- No preprocessor script is used for the queries. This makes the queries safe from modification by the user of the virtual schema.
- Only SELECT queries are allowed.
- Not allowed in batch mode.
- No query caching.