semantic

package
v2.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package semantic is the port through which the KPIs Cartograph records leave for, and later come back from, a semantic layer: the warehouse's own definitions of what each number is (TAXONOMY.md D57, docs/adr/0026). The engine builds a Layer from the record in the semantic layer's own terms (semantic models over warehouse models, measures, metrics) and an adapter writes it in one tool's syntax. The dbt adapter beside this package is the one implementation today; a distribution may add another.

Index

Constants

View Source
const (
	Simple     = "simple"
	Ratio      = "ratio"
	Cumulative = "cumulative"
	Derived    = "derived"
)

Metric types, as the semantic layer names them.

Variables

View Source
var ErrNoFormat = errors.New("no semantic layer exporter for that format")

ErrNoFormat is an export asked for in a syntax no exporter writes.

Functions

This section is empty.

Types

type Dimension

type Dimension struct {
	Name, Column string
}

Dimension is a categorical column a metric may be split by.

type Exporter

type Exporter interface {
	// Format names the syntax, such as dbt.
	Format() string
	Export(l Layer) ([]File, error)
}

Exporter writes a layer in one tool's syntax. The same layer always gives the same files.

type File

type File struct {
	Path    string
	Content []byte
}

File is one file an exporter writes.

type Importer

type Importer interface {
	Format() string
	Import(files []File) (Layer, error)
}

Importer reads a layer back from one tool's files, so metrics defined in the warehouse can be recorded as KPIs. No adapter implements it yet.

type Layer

type Layer struct {
	Models  []Model
	Metrics []Metric
}

Layer is a whole semantic layer: the models the data sources are and the metrics the KPIs are.

type Measure

type Measure struct {
	Name, Agg, Expr string
}

Measure is an aggregation over a model's rows.

type Metric

type Metric struct {
	// Name is the metric's name; KPI the KPI it is.
	Name, KPI          string
	Label, Description string
	Type               string
	// Measure is the measure of a simple or cumulative metric, by name.
	Measure string
	// Numerator and Denominator are, for a ratio, metrics by name.
	Numerator, Denominator string
	// Window is how far back a cumulative metric sums; empty for all time.
	Window string
	// Expr and Uses are a derived metric's expression and the metrics,
	// by name, it uses.
	Expr   string
	Uses   []string
	Filter string
}

Metric is one number, as the semantic layer defines it.

type Model

type Model struct {
	// Name is the semantic model's name; Source the data source it is.
	Name, Source string
	Description  string
	// Ref is the warehouse model it is built on.
	Ref string
	// Entity is what one row is, Key the column that names a row.
	Entity, Key string
	// TimeColumn is the time each row is counted at, Grain its finest.
	TimeColumn, Grain string
	Dimensions        []Dimension
	Measures          []Measure
}

Model is a semantic model: a data source as it sits in the warehouse.

Directories

Path Synopsis
Package conformance holds any semantic layer exporter to the port's promises: every KPI and data source in the layer is in what it writes, and the same layer always gives the same files.
Package conformance holds any semantic layer exporter to the port's promises: every KPI and data source in the layer is in what it writes, and the same layer always gives the same files.
Package dbt writes a semantic layer as dbt's: one YAML file of semantic_models and metrics, in the shape dbt's semantic layer reads (dbt 1.6 and later), for an analytics engineer to put in a dbt project beside the models it refers to.
Package dbt writes a semantic layer as dbt's: one YAML file of semantic_models and metrics, in the shape dbt's semantic layer reads (dbt 1.6 and later), for an analytics engineer to put in a dbt project beside the models it refers to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL