Schema Selector
Overview
The Schema Selector controls which DDN metadata (models, columns, and commands) are available to PromptQL. For large schemas, this optimizes performance, reduces costs, and improves accuracy by limiting the schema context sent to the LLM.
PromptQL provides three schema selection strategies:
Configuration Types
All Schema (Default)
Includes all available DDN metadata. This is the default behavior when schemaSelector
is not provided.
schemaSelector:
type: all
For complete configuration details, see AllSchema reference.
Fixed Schema
Explicitly specify which models and columns to include.
schemaSelector:
type: fixed
tables:
- schemaName: app # Subgraph name
tableName: users # Model name
columns: [id, name, email, created_at]
- schemaName: app
tableName: orders
columns: [id, user_id, total, status, created_at]
- schemaName: analytics # Different subgraph
tableName: user_metrics
columns: [] # Empty array includes all columns
Note: schemaName
refers to the subgraph name, tableName
refers to the model name.
For complete configuration details, see FixedSchema reference.
LLM-Assisted Schema Selection
Uses an LLM to intelligently select relevant schema elements for each user interaction. The selected schema is then provided to the PromptQL agent to fulfill the user's query.
schemaSelector:
type: llm_selector
llm:
provider: gemini
model: gemini-2.5-flash
apiKey:
valueFromEnv: GEMINI_API_KEY
maxItems: 25
instructions: Focus on user-related models and analytics commands
alwaysInclude:
tables:
app: [users, accounts] # Subgraph: [model names]
functions: [calculate_user_stats] # Command names
Configuration options:
maxItems
: Maximum number of models and commands to select (default: 25)instructions
: Custom guidance for the LLM selectoralwaysInclude
: Schema elements to always include
For complete configuration details, see SchemaSelector reference.
This approach is ideal for large schemas where query patterns are unpredictable. It provides automatic optimization by dynamically selecting the most relevant schema elements for each user interaction.
For large schemas, the LLM used for schema selection must have a large context window to handle the full schema.