Analytics & Advanced Workflows
This guide covers Loxtep's analytics engine and advanced workflow patterns. You will run SQL queries against data products and build multi-step transformation workflows.
Query Data Products with SQL
Loxtep embeds an analytics engine that lets you query any data product using standard SQL. Queries execute against the latest snapshot of the data product's contents.
Run a query against a data product:
SELECT customer_id, COUNT(*) as order_count, SUM(total_amount) as lifetime_value
FROM orders
WHERE created_at >= '2024-01-01'
GROUP BY customer_id
HAVING order_count > 5
ORDER BY lifetime_value DESC
LIMIT 20;
List Available Tables
Discover which data products are queryable in your current context:
{ "operation": "list_tables" }
Inspect Table Schema
View the column types and descriptions for a specific data product table:
{ "operation": "get_table_schema", "table_name": "orders" }
Scoped Queries
By default, queries run against all data products accessible to your organization. Scope queries to a specific data product for isolation:
{
"operation": "execute_query",
"sql": "SELECT * FROM orders WHERE total_amount > 1000",
"data_product_id": "<data-product-uuid>"
}
Retrieve Query Results
For large result sets, queries execute asynchronously. Retrieve results by query ID:
{ "operation": "get_query_results", "query_id": "<query-uuid>" }
Advanced Workflow Graphs
Workflows in Loxtep are directed acyclic graphs (DAGs) of processing nodes. Beyond simple ingestion, you can compose multi-step transformations, validations, and routing logic.
View the Workflow Graph
Inspect the current node topology of a workflow:
{
"operation": "get_workflow_graph",
"project_id": "<project-uuid>",
"workflow_id": "<workflow-uuid>"
}
Add Transformation Nodes
Append a transformation step that normalizes currency values to a base currency:
{
"operation": "patch_workflow_graph",
"project_id": "<project-uuid>",
"workflow_id": "<workflow-uuid>",
"operations": [
{
"op": "add_node",
"node": {
"id": "normalize_currency",
"type": "transform",
"config": { "target_currency": "USD" }
}
}
]
}
Preview Transformations
Test a transformation against sample data before deploying it:
{
"operation": "preview_transform",
"workflow_id": "<workflow-uuid>",
"transformation_id": "<transformation-uuid>",
"source_event": { "total_amount": 100, "currency": "EUR" },
"transform_config": {
"transform_type": "map",
"operation_config": { "expression": "record.total_amount * exchange_rate" }
}
}
Multi-Step Derivation Patterns
Fan-In Aggregation
Combine multiple source data products into a single consumer view by adding multiple source connections that converge at an aggregation node:
import { LoxtepClient } from '@loxtep/sdk';
const client = await LoxtepClient.fromWorkspace();
// Add multiple source connections to the workflow graph
const graph = await client.build.workflows.get_graph('wf_customer360', 'proj_analytics');
Then patch the graph via MCP to add the fan-in nodes:
{
"operation": "patch_workflow_graph",
"project_id": "proj_analytics",
"workflow_id": "wf_customer360",
"operations": [
{
"op": "add_node",
"node": { "id": "orders_source", "type": "connection", "connection_id": "conn_orders" }
},
{
"op": "add_node",
"node": { "id": "profiles_source", "type": "connection", "connection_id": "conn_profiles" }
},
{
"op": "add_node",
"node": {
"id": "merge",
"type": "transform",
"config": { "strategy": "join", "key": "customer_id" }
}
},
{ "op": "add_edge", "from": "orders_source", "to": "merge" },
{ "op": "add_edge", "from": "profiles_source", "to": "merge" }
]
}
Fan-Out Routing
Route records to different destinations based on content. For example, split orders by region into separate data products:
{
"operation": "patch_workflow_graph",
"project_id": "proj_commerce",
"workflow_id": "wf_order_router",
"operations": [
{
"op": "add_node",
"node": {
"id": "router",
"type": "transform",
"config": { "type": "route", "field": "region" }
}
},
{
"op": "add_node",
"node": { "id": "us_sink", "type": "destination", "data_product_id": "dp_orders_us" }
},
{
"op": "add_node",
"node": { "id": "eu_sink", "type": "destination", "data_product_id": "dp_orders_eu" }
},
{ "op": "add_edge", "from": "router", "to": "us_sink", "condition": "region == 'us'" },
{ "op": "add_edge", "from": "router", "to": "eu_sink", "condition": "region == 'eu'" }
]
}
Workspace Versioning
Advanced workflows benefit from version control. Loxtep tracks every change to workflow graphs as a version, enabling safe rollbacks.
Create a Snapshot
Before making significant changes, create a labeled snapshot:
{
"operation": "create_snapshot",
"description": "pre-currency-normalization",
"snapshot_type": "manual"
}
Compare Versions
Review what changed between two versions:
{
"operation": "compare_versions",
"version_a": "<older-commit-sha>",
"version_b": "<newer-commit-sha>"
}
Restore a Previous Version
Restore in Studio with an instance selected, or via hosted MCP restore_version
with both version_id (commit SHA) and instance_id (target instance workspace).
Omitting instance_id fails validation.
{
"operation": "restore_version",
"version_id": "<commit-sha>",
"instance_id": "<instance-uuid>"
}
Event Replay
For streaming data products, replay historical events through a workflow to reprocess data after a transformation change:
{
"operation": "replay_events",
"data_product_id": "<data-product-uuid>",
"from_timestamp": "2024-06-01T00:00:00Z",
"limit": 1000
}
Replay re-executes the current workflow graph against historical events, updating the data product with the corrected outputs.