KDB-X Module Support in kdb Insights Enterprise¶
This page provides an overview of KDB-X module support in kdb Insights Enterprise, explaining how modules are packaged, distributed, and loaded across your deployments. To start creating and using modules, refer to Develop with KDB-X Modules.
KDB-X introduces a first-class module system that allows q code to be packaged as self-contained, reusable units with their own namespaces. In kdb Insights Enterprise, you can use modules in User-Defined Analytics (UDAs), pipelines, Scratchpad sessions, and KDB-X Workloads.
How it works¶
kdb Insights Enterprise ships with kdb Insights Core built on KDB-X, bringing native module support to the product. You can use KDB-X modules across your deployments in the same way as any other KDB-X process – no additional configuration required.
Modules and packages¶
KDB-X modules are deployed to kdb Insights Enterprise as packages: add a manifest.yaml – the package descriptor required for any kdb Insights Enterprise package – to the top level of your module directory. The key difference from a standard package is that a KDB-X module's source code follows the KDB-X module spec.
Pushing a module to kdb Insights Enterprise¶
- Write your module according to the KDB-X module spec.
- Add a
manifest.yamlat the top level of your module directory with at leastnameandversion. - Push it to your kdb Insights Enterprise instance using
kxi pm push.
Using a module in a package or workload¶
- Declare the module as a dependency in the
manifest.yamlat the root of your package – refer to Package Dependency. - Import and use it in your source code:
.utils: use `myutils;
.utils.greet "world"
Refer to KDB-X modules for a full walkthrough.
Module behaviour in kdb Insights Enterprise¶
kdb Insights Enterprise components that support UDAs and UDFs – DAPs, Aggregators, and pipelines – follow the standard module dependency model described in KDB-X modules. The following sections cover the Global Aggregator and Scratchpad, which have kdb Insights Enterprise-specific behaviour that requires additional consideration.
Using modules with the Global Aggregator¶
The Global Aggregator supports loading KDB-X modules, allowing UDAs to call into module functions directly without bundling the module code inside the package itself.
Unlike DAPs, Aggregators, and pipelines, the Global Aggregator does not support declaring module dependencies via manifest.yaml. Instead, modules must be loaded either at runtime using kxi pm load (requires the package admin role) or persistently via KX_PACKAGES – refer to Loading UDAs into Global Aggregators for details.
Loading modules in a Scratchpad¶
Install KDB-X modules into a running Scratchpad session using the .kxi.install function. This allows your Scratchpad code to use modules in the same way as any other KDB-X process, making local development and production code look identical.
Loading KDB-X modules in a Scratchpad is useful for:
- Pipeline testing – testing pipelines that depend on custom modules through the Scratchpad test interface.
- Data analysis – ad-hoc analysis using module functions within a Scratchpad session.
- Executing code – running q code that imports and uses KDB-X modules.
- Manual pipeline execution – for example, calling
.qsp.runin a session that requires module dependencies.
Refer to KDB-X modules for details on creating and pushing modules, and the .kxi.install reference for the full API.