Skip to content

Load the SQL surface into any Flink session as a module - #78

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:feat/sql-module
Oct 10, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:feat/sql-module

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

LOAD MODULE mobilitydb brings the whole generated SQL surface into a SQL session that runs
plain SQL, the SQL Client, the SQL Gateway or tEnv.executeSql, with no Java call.
MobilityDBModuleFactory, named in META-INF/services/org.apache.flink.table.factories.Factory,
answers the identifier with MobilityDBModule, which holds every function
MobilityFlinkSql.registerAll registers, under the same names and as the same classes. The
module reads them from registerAll itself, run once on a table environment that records each
createTemporaryFunction(name, class) call and refuses any other, so the generated registration
stays the one list of the surface and the module carries no list of its own. registerAll is
unchanged, and a table environment holding the module may still call it.

The identifier follows the convention of Flink's own module factories: core names the module
of Flink's functions and hive the module of Hive's, the system whose functions the module
brings rather than the Flink project that ships it, so the module of MobilityDB's functions is
mobilitydb, the name PostgreSQL's CREATE EXTENSION gives the same surface.

A module function is a system function, resolved module by module in the order SHOW MODULES
lists, after the core module LOAD MODULE leaves first. Of the 1179 functions the module holds,
17 share a name with the core module (abs, ceil, collect, cos, degrees, exp, floor, initcap,
ln, log10, lower, radians, reverse, round, sin, tan, upper); these answer with Flink's built-in
until USE MODULES mobilitydb, core lists the module first, as a catalog function of the same
name answers only qualified. GENERATION.md states both ways in.

MobilityDBModuleTest creates table environments that never call registerAll: after LOAD MODULE
mobilitydb, asText of a tfloat built by its constructor and from text answers
1.5@2020-01-01 00:00:00+00, SHOW MODULES lists core then mobilitydb, the module lists exactly
the functions listUserDefinedFunctions reports after registerAll, a query plans to the same
column types either way, lower(floatspan) answers 1.0 once the module comes first, and
registerAll beside the module answers alike. Without the service entry, each test that runs
LOAD MODULE fails on "Could not find any factory for identifier 'mobilitydb'".

Measured over MobilityDB 1f41894b35, the catalog of MEOS-API ff5f838173 and the generator and
jar of JMEOS ef197a0262: the binding module passes its 30 tests and the benchmark module its
12, and the build prints no warning. With the window-aggregate test of main the suite holds 43
tests, the workflow's floor.

`LOAD MODULE mobilitydb` brings the whole generated SQL surface into a SQL session that runs
plain SQL, the SQL Client, the SQL Gateway or tEnv.executeSql, with no Java call.
MobilityDBModuleFactory, named in META-INF/services/org.apache.flink.table.factories.Factory,
answers the identifier with MobilityDBModule, which holds every function
MobilityFlinkSql.registerAll registers, under the same names and as the same classes. The
module reads them from registerAll itself, run once on a table environment that records each
createTemporaryFunction(name, class) call and refuses any other, so the generated registration
stays the one list of the surface and the module carries no list of its own. registerAll is
unchanged, and a table environment holding the module may still call it.

The identifier follows the convention of Flink's own module factories: `core` names the module
of Flink's functions and `hive` the module of Hive's, the system whose functions the module
brings rather than the Flink project that ships it, so the module of MobilityDB's functions is
`mobilitydb`, the name PostgreSQL's CREATE EXTENSION gives the same surface.

A module function is a system function, resolved module by module in the order SHOW MODULES
lists, after the core module LOAD MODULE leaves first. Of the 1179 functions the module holds,
17 share a name with the core module (abs, ceil, collect, cos, degrees, exp, floor, initcap,
ln, log10, lower, radians, reverse, round, sin, tan, upper); these answer with Flink's built-in
until USE MODULES mobilitydb, core lists the module first, as a catalog function of the same
name answers only qualified. GENERATION.md states both ways in.

MobilityDBModuleTest creates table environments that never call registerAll: after LOAD MODULE
mobilitydb, asText of a tfloat built by its constructor and from text answers
1.5@2020-01-01 00:00:00+00, SHOW MODULES lists core then mobilitydb, the module lists exactly
the functions listUserDefinedFunctions reports after registerAll, a query plans to the same
column types either way, lower(floatspan) answers 1.0 once the module comes first, and
registerAll beside the module answers alike. Without the service entry, each test that runs
LOAD MODULE fails on "Could not find any factory for identifier 'mobilitydb'".

Measured over MobilityDB 1f41894b35, the catalog of MEOS-API ff5f838173 and the generator and
jar of JMEOS ef197a0262: the binding module passes its 30 tests and the benchmark module its
12, and the build prints no warning. With the window-aggregate test of main the suite holds 43
tests, the workflow's floor.
@estebanzimanyi
estebanzimanyi merged commit 137eb89 into MobilityDB:main Oct 10, 2026
2 checks passed
@estebanzimanyi
estebanzimanyi deleted the feat/sql-module branch October 11, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant