Semantic Model configuration
Download JSON Schema
Example
apiVersion: leapview.dev/v1
kind: SemanticModel
metadata:
workspace: movielens
name: genre_ratings
title: Genre Ratings Semantic Model
description: Rating-by-genre semantic model for safe genre analysis.
spec:
tables:
- rating_genres
- ratings
- movies
- users
relationships:
- id: rating_genres_movies
description: Links each rating-genre row to the rated movie.
from: rating_genres.movie_id
to: movies.movie_id
cardinality: many_to_one
- id: rating_genres_users
description: Links each rating-genre row to the anonymized user who made the rating.
from: rating_genres.user_id
to: users.user_id
cardinality: many_to_one
dimensions:
rating_date:
type: date
bindings:
rating_genres: {field: rating_genres.rating_date}
genre:
type: string
bindings:
rating_genres: {field: rating_genres.genre}
release_decade:
type: string
bindings:
rating_genres: {field: rating_genres.release_decade}
measures:
genre_rating_count:
label: Genre ratings
description: Count of rating-genre rows.
fact: rating_genres
aggregation: count
empty: zero
format: integer
average_rating:
label: Average rating
description: Average MovieLens rating for the rating-genre rows.
fact: rating_genres
aggregation: avg
input: {field: rating_genres.rating}
empty: "null"
format: decimal
active_users:
label: Active users
description: Distinct users represented by the rating-genre rows.
fact: rating_genres
aggregation: count_distinct
input: {field: rating_genres.user_id}
empty: zero
format: integer
rated_movies:
label: Rated movies
description: Distinct movies represented by the rating-genre rows.
fact: rating_genres
aggregation: count_distinct
input: {field: rating_genres.movie_id}
empty: zero
format: integer
Fields
| Field |
Type |
Required |
Rules |
apiVersion |
APIVersion |
Yes |
|
kind |
SemanticModel |
Yes |
|
metadata |
Metadata |
Yes |
|
spec |
ProjectSemanticModelSpec |
Yes |
|
Nested definitions
APIVersion
| Field |
Type |
Required |
Rules |
FieldRef
| Field |
Type |
Required |
Rules |
Identifier
| Field |
Type |
Required |
Rules |
Measure
| Field |
Type |
Required |
Rules |
aggregation |
object |
Yes |
one of sum, count, count_distinct, avg, min, max |
description |
string |
No |
|
empty |
object |
Yes |
one of zero, null |
fact |
Identifier |
Yes |
|
filters |
array of object |
No |
|
format |
string |
No |
|
hidden |
boolean |
No |
|
input |
object |
No |
no additional fields |
label |
string |
No |
|
unit |
string |
No |
|
| Field |
Type |
Required |
Rules |
description |
string |
No |
|
name |
ResourceID |
Yes |
|
owner |
string |
No |
|
tags |
array of string |
No |
|
title |
string |
No |
|
workspace |
ResourceID |
No |
|
Metric
| Field |
Type |
Required |
Rules |
description |
string |
No |
|
expression |
string |
Yes |
|
format |
string |
No |
|
hidden |
boolean |
No |
|
label |
string |
No |
|
unit |
string |
No |
|
ProjectSemanticModelSpec
| Field |
Type |
Required |
Rules |
dimensions |
object |
No |
no additional fields |
measures |
object |
Yes |
no additional fields |
metrics |
object |
No |
no additional fields |
relationships |
array of Relationship |
No |
|
tables |
array of Identifier |
Yes |
|
Relationship
| Field |
Type |
Required |
Rules |
cardinality |
object |
Yes |
one of many_to_one, one_to_one |
description |
string |
No |
|
from |
FieldRef |
Yes |
|
id |
Identifier |
Yes |
|
to |
FieldRef |
Yes |
|
ResourceID
| Field |
Type |
Required |
Rules |
SemanticDimension
| Field |
Type |
Required |
Rules |
bindings |
object |
Yes |
no additional fields |
description |
string |
No |
|
grains |
array of object |
No |
|
label |
string |
No |
|
type |
object |
Yes |
one of string, number, boolean, date, timestamp |