Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:4paradigm OpenMLDB SQL Deploy Statement

From Leeroopedia
Knowledge Sources
Domains Database, Feature_Engineering
Last Updated 2026-10-12 12:00 GMT

Overview

SQL deployment statement for registering a feature engineering query as a named online deployment in OpenMLDB.

Description

The DEPLOY statement is OpenMLDB's mechanism for transitioning a feature engineering SQL query from offline development to online serving. When a SQL query is deployed, OpenMLDB compiles it into an optimized execution plan, pre-allocates resources, and registers the deployment with a unique name. The deployed query can then be served via the HTTP API or SDK with sub-millisecond latency for real-time feature computation. The deployment process involves the TaskManager for offline job execution and the nameserver for metadata registration.

Usage

Use this pattern after validating a feature engineering SQL query in offline mode. Deploy the query to make it available for online serving. The deployment name is used in subsequent HTTP/SDK queries to invoke the pre-compiled plan.

Code Reference

Source Location

  • Repository: OpenMLDB
  • File: src/flags.cc (deploy job flags at L186-188), demo/docker-compose.test.yml (deployment verification at L66)

Signature

-- Deploy a SQL query for online serving
DEPLOY <deployment_name> <sql_statement>;

-- Example: Deploy a windowed aggregation query
DEPLOY demo
SELECT sum(trip_distance) OVER w1 as total_distance
FROM taxi_tour
WINDOW w1 AS (PARTITION BY license PARTITION BY id ORDER BY trip_time ROWS BETWEEN 60 PRECEDING AND CURRENT ROW);

Related Configuration (from src/flags.cc)

DEFINE_int32(sync_job_timeout, 30*60*1000,
    "sync job timeout, unit is milliseconds");                            // L186-187
DEFINE_int32(deploy_job_max_wait_time_ms, 30*60*1000,
    "the max wait time of waiting deploy job");                            // L188

Import

# Deploy via SQL client
openmldb --role=sql_client \
    --zk_cluster=<zk> --zk_root_path=<path> \
    --interactive=false \
    --cmd="DEPLOY demo SELECT ..."

I/O Contract

Inputs

Name Type Required Description
deployment_name string Yes Unique name for the deployment (e.g. demo)
sql_statement string Yes Validated SQL feature query (SELECT with WINDOW, LAST JOIN, etc.)
sync_job_timeout int32 No Sync job timeout in ms (default: 30 min)
deploy_job_max_wait_time_ms int32 No Max wait time for deploy job (default: 30 min)

Outputs

Name Type Description
Named deployment metadata Deployment registered in OpenMLDB, query compiled and ready for online serving
HTTP endpoint URL POST /dbs/{db} with deployment name for online queries

Usage Examples

Deploy a Feature Query

-- Create and deploy a feature engineering query
CREATE DATABASE demo_db;
USE demo_db;

-- Create source table
CREATE TABLE taxi_tour (
    id string,
    trip_distance double,
    trip_time timestamp,
    license string
);

-- Deploy the feature query
DEPLOY demo
SELECT sum(trip_distance) OVER w1 as total_distance,
       avg(trip_distance) OVER w1 as avg_distance
FROM taxi_tour
WINDOW w1 AS (
    PARTITION BY license
    PARTITION BY id
    ORDER BY trip_time
    ROWS BETWEEN 60 PRECEDING AND CURRENT ROW
);

Verify Deployment

# Verify deployment via HTTP API
curl http://127.0.0.1:9080/dbs/demo_db/deployments/demo
# Expected response contains "ok"

# Show all deployments via CLI
openmldb --role=sql_client \
    --zk_cluster=127.0.0.1:2181 \
    --zk_root_path=/openmldb \
    --interactive=false \
    --cmd="SHOW DEPLOYMENT demo"

Related Pages

Implements Principle

Requires Environment

Page Connections

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