Integrate with AI
Semantic View provides a business-friendly query layer. There are three main ways to integrate with AI capabilities: directly calling AI functions in SQL to process semantic query results, using CZ-CLI to let AI Agents operate on semantic views, and integrating into AI workflows via MCP Server tools.
AI_COMPLETE Combined Queries
The results of semantic_view() are standard result sets and can be passed directly to AI_COMPLETE in the SELECT list for AI processing of each row.
Typical scenarios: Generating natural language interpretations, anomaly analysis, or summaries for metric results returned by semantic views.
You can also materialize semantic view results before performing batch AI processing:
Using CZ-CLI
CZ-CLI is the currently recommended method for AI Agent access, supporting natural language-driven operations on semantic views.
View semantic views under the current schema:
Query a semantic view:
Create a semantic view:
See CZ-CLI Documentation for details.
MCP Server Tools
The Singdata Lakehouse MCP Server provides a set of tools specifically for semantic views, which can be integrated into AI Agent frameworks (Dify, N8N, Claude Desktop, etc.). See MCP Server Documentation for details.
Tool Overview
| Tool Name | Operation | Description |
|---|---|---|
LH-create-semantic-view | Create | Create a semantic view from a YAML definition |
LH-desc-semantic-view | View | Get the complete YAML definition of a view |
LH-desc-logical-table | View | Get logical table structure and relationships |
LH-brief-semantic-view | View | Quickly browse dimension and metric fields |
LH-get_semantic_view_dims | View | Get structured dimension list |
LH-semantic-view-dim-add | Modify | Dynamically add a dimension (no rebuild needed) |
LH-semantic-view-dim-del | Modify | Dynamically delete a dimension (no rebuild needed) |
LH-query-semantic-value | Query | Structured parameter-driven query, recommended for Agents |
Typical Agent Workflow
LH-query-semantic-value
This is the recommended way for AI Agents to query semantic views, without needing to manually write semantic_view() SQL:
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
semantic_view_name | string | Yes | Name of the semantic view |
selected_dimensions | array | Yes | List of dimensions to query |
selected_metrics | array | Yes | List of metrics to query |
filter_conditions | array | No | Filter conditions (default empty) |
Example:
Equivalent SQL:
LH-semantic-view-dim-add
Dynamically add a dimension to an existing semantic view without rebuilding:
LH-create-semantic-view
Create a semantic view from a YAML definition, suitable for declarative configuration or cross-environment migration:
The YAML format is compatible with the Snowflake Cortex Analyst specification. Use LH-desc-semantic-view to export an existing view as YAML.
