Implementation:TobikoData Sqlmesh Model SqlmeshModel
| Knowledge Sources | |
|---|---|
| Domains | Web_UI, Data_Models, Model_Metadata |
| Last Updated | 2026-02-07 20:00 GMT |
Overview
Model representation for SQLMesh data models in the web UI containing metadata, schema, lineage, and source definitions.
Description
ModelSQLMeshModel represents a SQLMesh data model in the web application with comprehensive metadata including columns, description, SQL definitions, model type (sql, python, seed, external), and details for search indexing. The class provides intelligent property management with URI encoding for names/FQNs, computed search indexes combining all metadata fields, and type-specific utilities for determining model kinds.
Key features include automatic URI encoding/decoding for model names, details property with automatic indexing for search functionality, comprehensive search index property combining name/path/type/columns/details/dialect/description, model type detection (isModelPython, isModelSQL, isModelSeed, isModelExternal), and update() method for partial model updates.
The model includes optional lineage data for dependency tracking and supports catalog/schema organization through default_catalog property.
Usage
Use this class to display model information in the data catalog, search functionality, and model detail views throughout the SQLMesh web UI.
Code Reference
Source Location
- Repository: TobikoData_Sqlmesh
- File: web/client/src/models/sqlmesh-model.ts
Signature
export class ModelSQLMeshModel<
T extends InitialSQLMeshModel = InitialSQLMeshModel
> extends ModelInitial<T> {
_details: ModelDetails = {}
_detailsIndex: string = ''
name: string
fqn: string
path: string
full_path: string
dialect: string
type: ModelType
columns: Column[]
default_catalog?: ModelDefaultCatalog
description?: ModelDescription
sql?: ModelSql
definition?: ModelDefinition
hash: string
constructor(initial?: T | ModelSQLMeshModel)
get defaultCatalog(): Optional<ModelDefaultCatalog>
get details(): ModelDetails
set details(details: ModelDetails)
get index(): string
get isModelPython(): boolean
get isModelSQL(): boolean
get isModelSeed(): boolean
get isModelExternal(): boolean
get displayName(): string
update(initial: Partial<InitialSQLMeshModel>): void
}
Import
import { ModelSQLMeshModel } from '@models/sqlmesh-model'
import { ModelType } from '@api/client'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| initial | ModelSQLMeshModel | No | Model metadata from API |
Outputs
| Property | Type | Description |
|---|---|---|
| name | string | URI-encoded model name |
| fqn | string | URI-encoded fully qualified name |
| displayName | string | Decoded display name for UI |
| path | string | File path to model definition |
| full_path | string | Full absolute file path |
| dialect | string | SQL dialect (e.g., "Default", "snowflake") |
| type | ModelType | Model type (sql, python, seed, external) |
| columns | Column[] | Schema column definitions |
| description | ModelDescription | Model description metadata |
| sql | ModelSql | Compiled SQL query |
| definition | ModelDefinition | Raw model definition source |
| hash | string | Model hash/fingerprint |
| index | string | Searchable text index of all metadata |
| details | ModelDetails | Additional structured metadata |
Usage Examples
// Create model from API response
const model = new ModelSQLMeshModel({
name: 'my_schema.my_model',
fqn: 'prod.my_schema.my_model',
path: 'models/my_model.sql',
full_path: '/project/models/my_model.sql',
dialect: 'snowflake',
type: ModelType.sql,
columns: [
{ name: 'id', type: 'INT' },
{ name: 'name', type: 'VARCHAR' }
],
description: 'Customer data model',
hash: 'abc123',
details: {
owner: 'data-team',
tags: ['customer', 'core']
}
})
// Display name (decoded)
console.log(model.displayName) // "my_schema.my_model"
// Check model type
if (model.isModelSQL) {
console.log('SQL model:', model.sql)
} else if (model.isModelPython) {
console.log('Python model:', model.definition)
}
// Search across all metadata
const searchQuery = 'customer'
if (model.index.toLowerCase().includes(searchQuery)) {
console.log('Model matches search')
}
// Update specific fields
model.update({
columns: [
{ name: 'id', type: 'BIGINT' },
{ name: 'name', type: 'VARCHAR' },
{ name: 'email', type: 'VARCHAR' }
],
description: 'Updated customer data model'
})
// Access catalog information
if (model.defaultCatalog) {
console.log(`Catalog: ${model.defaultCatalog}`)
}
// Check for specific file type
if (model.isModelSeed) {
console.log('This is a seed data model')
}