Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Druid Parameter Model

From Leeroopedia


Knowledge Sources
Domains Web_Console, Data_Visualization
Last Updated 2026-02-10 10:00 GMT

Overview

The Parameter model defines the type system and utility functions for managing configurable parameters within explore view visualization modules.

Description

This module provides the ParameterDefinition type hierarchy, which supports typed parameters including string, boolean, number, option (single selection), options (multi-selection), expression, expressions, measure, and measures. Each parameter definition can declare labels, default values, visibility conditions, sticky persistence, transfer groups for cross-module parameter migration, and validation rules -- all expressed as static values or functors that receive the current query context. The module also provides utility functions for inflating serialized parameter values, removing undefined parameters, computing effective defaults, and renaming columns within parameter values.

Usage

The Parameter model is used when registering modules in the ModuleRepository (each module declares its parameters as a Record of ParameterDefinition), by the ControlPane for rendering parameter editors, by the ModulePane for filling in defaults and managing sticky state, and by the explore state for serialization and deserialization of module configurations.

Code Reference

Source Location

Signature

export type OptionValue = string | number;

export type ModuleFunctor<T> =
  | T
  | ((options: {
      querySource: QuerySource | undefined;
      where: SqlExpression;
      parameterValues: ParameterValues;
    }) => T);

export function evaluateFunctor<T>(
  functor: ModuleFunctor<T> | undefined,
  parameterValues: ParameterValues,
  querySource: QuerySource | undefined,
  where: SqlExpression,
): T | undefined;

export type TypedParameterDefinition<Type extends keyof ParameterTypes>;
export type ParameterDefinition = /* union of all TypedParameterDefinition variants */;
export type ParameterValues = Readonly<Record<string, any>>;
export type Parameters = Readonly<Record<string, ParameterDefinition>>;

export function getModuleOptionLabel(
  optionValue: OptionValue,
  parameterDefinition: ParameterDefinition,
): string;

export function inflateParameterValues(
  parameterValues: ParameterValues | undefined,
  parameters: Parameters,
): ParameterValues;

export function removeUndefinedParameterValues(
  parameterValues: ParameterValues,
  parameters: Parameters,
  querySource: QuerySource | undefined,
  where: SqlExpression,
): ParameterValues;

export function effectiveParameterDefault(
  parameter: ParameterDefinition,
  parameterValues: ParameterValues,
  querySource: QuerySource | undefined,
  where: SqlExpression,
  previousParameterValue: any,
): any;

export function renameColumnsInParameterValues(
  parameterValues: ParameterValues,
  parameters: Parameters,
  rename: Map<string, string>,
): ParameterValues;

Import

import {
  ParameterDefinition,
  ParameterValues,
  inflateParameterValues,
  effectiveParameterDefault,
} from './views/explore-view/models/parameter';

I/O Contract

Inputs

Name Type Required Description
type keyof ParameterTypes Yes The parameter type: 'string', 'boolean', 'number', 'option', 'options', 'expression', 'expressions', 'measure', or 'measures'
label ModuleFunctor<string> No Display label for the parameter, can be a string or functor
defaultValue ModuleFunctor<T> No Default value or functor that computes it from the current query context
sticky boolean No Whether the parameter value should persist across module changes via localStorage
transferGroup string No Group identifier used to transfer values when switching between compatible modules
required ModuleFunctor<boolean> No Whether the parameter is required
important boolean No Whether the parameter should be shown prominently in the compact control pane
visible ModuleFunctor<boolean> No Whether the parameter should be visible in the UI
defined ModuleFunctor<boolean> No Whether the parameter is defined (undefined parameters are removed from state)

Outputs

Name Type Description
ParameterValues Record<string, any> Inflated, validated, and default-filled parameter values ready for module consumption

Usage Examples

Defining parameters for a module

const parameters: Record<string, ParameterDefinition> = {
  splitColumn: {
    type: 'expression',
    label: 'Group by column',
    transferGroup: 'show',
    required: true,
    important: true,
  },
  measure: {
    type: 'measure',
    defaultValue: ({ querySource }) => querySource?.getFirstAggregateMeasure(),
    required: true,
  },
  limit: {
    type: 'number',
    defaultValue: 10,
    min: 1,
    max: 1000,
  },
};

Inflating serialized parameter values

const inflated = inflateParameterValues(savedValues, module.parameters);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment