Skip to content

Instantly share code, notes, and snippets.

@jlee9595
Created July 26, 2024 20:46
Show Gist options
  • Save jlee9595/c2614cac7dad644f3acf4029b96e046d to your computer and use it in GitHub Desktop.
Save jlee9595/c2614cac7dad644f3acf4029b96e046d to your computer and use it in GitHub Desktop.
spec
{
"$defs": {
"Description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "Object description",
"title": "Description"
},
"Dimension": {
"description": "Pydantic model for a dimension specification",
"properties": {
"name": {
"description": "The name of the dimension.",
"title": "DimensionName",
"type": "string"
},
"type": {
"description": "The type of the dimension (e.g., string, number, boolean, time).",
"enum": [
"boolean",
"date",
"null",
"number",
"other",
"string",
"time",
"timestamp",
"timestamptz"
],
"title": "DimensionType",
"type": "string"
},
"sql": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "An SQL expression for the dimension. If not provided, the name is used as the expression.",
"title": "DimensionSql"
},
"primary_key": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Indicates if this dimension is the primary key.",
"title": "DimensionPrimaryKey"
},
"title": {
"anyOf": [
{
"$ref": "#/$defs/Title"
},
{
"type": "null"
}
],
"default": null
},
"description": {
"anyOf": [
{
"$ref": "#/$defs/Description"
},
{
"type": "null"
}
],
"default": null
},
"format": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The format of the dimension's value.",
"title": "DimensionFormat"
},
"meta": {
"anyOf": [
{
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"description": "Additional metadata for the dimension.",
"title": "DimensionMeta"
}
},
"required": [
"name",
"type"
],
"title": "Dimension",
"type": "object"
},
"Dimensions": {
"description": "List of dimensions for the dataset.",
"items": {
"$ref": "#/$defs/Dimension"
},
"title": "Dimensions",
"type": "array"
},
"Join": {
"description": "Pydantic model for a join specification",
"properties": {
"target": {
"description": "The name of the target dataset to join to",
"title": "JoinTarget",
"type": "string"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The name of the join, defaults to the target dataset name if not provided",
"title": "JoinName"
},
"relationship": {
"allOf": [
{
"$ref": "#/$defs/RelationshipType"
}
],
"description": "The type of relationship between the datasets (e.g., one_to_one, one_to_many, many_to_one).",
"title": "JoinRelationship"
},
"sql": {
"description": "The SQL expression that defines the join condition.",
"title": "JoinSQL",
"type": "string"
}
},
"required": [
"target",
"relationship",
"sql"
],
"title": "Join",
"type": "object"
},
"Joins": {
"description": "List of joins for the dataset.",
"items": {
"$ref": "#/$defs/Join"
},
"title": "Joins",
"type": "array"
},
"Measure": {
"description": "Pydantic model for a measure specification",
"properties": {
"name": {
"description": "The identifier of the measure. Must be unique within the dataset.",
"title": "MeasureName",
"type": "string"
},
"sql": {
"description": "The SQL expression to aggregate for the measure.",
"title": "MeasureSql",
"type": "string"
},
"type": {
"allOf": [
{
"$ref": "#/$defs/MeasureType"
}
],
"description": "The type of the measure. Either a datatype (number, boolean, string, timestamp, etc.) or an aggregation type (count, sum, avg, min, max, etc.)."
},
"title": {
"anyOf": [
{
"$ref": "#/$defs/Title"
},
{
"type": "null"
}
],
"default": null
},
"description": {
"anyOf": [
{
"$ref": "#/$defs/Description"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
"name",
"sql",
"type"
],
"title": "Measure",
"type": "object"
},
"MeasureType": {
"description": "Enum for the type of measure.",
"enum": [
"count",
"sum",
"avg",
"min",
"max",
"null",
"number",
"string",
"date",
"time",
"timestamp",
"timestamptz",
"boolean",
"other"
],
"title": "MeasureType",
"type": "string"
},
"Measures": {
"description": "List of measures for the dataset.",
"items": {
"$ref": "#/$defs/Measure"
},
"title": "Measures",
"type": "array"
},
"RelationshipType": {
"description": "Enum for the type of join relationship between datasets.",
"enum": [
"one_to_one",
"many_to_one"
],
"title": "RelationshipType",
"type": "string"
},
"Segment": {
"description": "Pydantic model for a segment specification",
"properties": {
"name": {
"description": "The identifier of the segment. Must be unique among all segments, dimensions, and measures within a dataset.",
"title": "SegmentName",
"type": "string"
},
"sql": {
"description": "The SQL expression that defines how the segment filters data.",
"title": "SegmentSql",
"type": "string"
},
"title": {
"anyOf": [
{
"$ref": "#/$defs/Title"
},
{
"type": "null"
}
],
"default": null
},
"description": {
"anyOf": [
{
"$ref": "#/$defs/Description"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
"name",
"sql"
],
"title": "Segment",
"type": "object"
},
"Segments": {
"description": "List of segments for the dataset.",
"items": {
"$ref": "#/$defs/Segment"
},
"title": "Segments",
"type": "array"
},
"Title": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "Display title",
"title": "Title"
}
},
"description": "Pydantic model for a dataset specification",
"oneOf": [
{
"required": [
"sql"
]
},
{
"required": [
"sql_table"
]
}
],
"properties": {
"name": {
"description": "The name of the dataset.",
"title": "DatasetName",
"type": "string"
},
"sql": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The source SQL query for the dataset.",
"title": "DatasetSql"
},
"sql_table": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The source SQL table for the dataset.",
"title": "DatasetSqlTable"
},
"dimensions": {
"anyOf": [
{
"$ref": "#/$defs/Dimensions"
},
{
"type": "null"
}
],
"default": null
},
"measures": {
"anyOf": [
{
"$ref": "#/$defs/Measures"
},
{
"type": "null"
}
],
"default": null
},
"segments": {
"anyOf": [
{
"$ref": "#/$defs/Segments"
},
{
"type": "null"
}
],
"default": null
},
"joins": {
"anyOf": [
{
"$ref": "#/$defs/Joins"
},
{
"type": "null"
}
],
"default": null
},
"title": {
"anyOf": [
{
"$ref": "#/$defs/Title"
},
{
"type": "null"
}
],
"default": null
},
"description": {
"anyOf": [
{
"$ref": "#/$defs/Description"
},
{
"type": "null"
}
],
"default": null
}
},
"required": [
"name"
],
"title": "Dataset",
"type": "object"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment