Lynk docs
  • Introduction
  • Reference
    • Data Modeling
      • Entities
      • Relationships
        • Entity-to-Entity Relations
        • Entity-to-Asset Relations
      • Features
        • Field
        • Metric
        • First-Last
        • Formula
        • Filters
        • Chaining Features
      • Measures
      • Data Assets
      • Time Aggregations
      • Lynk Functions
        • POP
      • Context
    • Consume & APIs
      • Authentication
      • SQL API
      • SQL REST API
      • Cache & Pre-Aggregations
    • Governance
    • Integrations
      • Git
      • Query Engines
    • AI Agents
Powered by GitBook
LogoLogo

Start now

  • Request Access

Website

  • Home
On this page
  • Simple metric feature
  • type
  • name
  • asset
  • join_name [optional]
  • data_type [optional]
  • time_field [optional]
  • measure
  • filters
  • Understanding Metric features
  1. Reference
  2. Data Modeling
  3. Features

Metric

PreviousFieldNextFirst-Last

Last updated 2 days ago

Metric features are great for aggregations from one-to-many relations. It is commonly used to enrich an entity with aggregated fields from one-to-many related assets or entities.

When we create a metric feature, we apply a aggregation to the level of an entity.


Simple metric feature

In this example, we define simple metric features for the entity customer:

# customer.yml

features:
  
- type: metric
  name: orders_count
  asset: db_prod.core.orders
  measure: orders_count
  data_type: number
  filters: null

- type: metric
  name: successful_orders_count
  asset: db_prod.core.orders
  measure: orders_count
  data_type: number
  time_field: order_date
  filters:
  - type: field
    field: order_status
    operator: is
    values:
    - success

type

The feature type. In case of metric features, it should be set to metric.

name

Give the metric feature a name.

asset

The data asset with the measure to be aggregated to the level of our entity. asset should be the full path: "db.schema.name".

join_name [optional]

In case multiple join patterns are defined between an entity and a data asset, join_name is used to determine which join path to use for a specific feature.

data_type [optional]

Specify the feature data type. If no data_type specified, Lynk will assume the data type is string.

The options for data types are:

string

For any type of string data type

number

For any type of number data type. For example: integer, float, decimal etc..

datetime

For any type of time-based data type. For example: date, timestamp, datetime etc..

bool

For boolean data type.

time_field [optional]

measure

The name of the measure we would like to aggregate from the related asset to the level of our entity.

filters

Understanding Metric features

To better understand how Field features work, look the following diagram;

The above diagram shows an example when a customer (entity) has many orders (data asset). That means, each customer can be associated with many rows in db.schema.orders.

In this case, we took the measure total_price which translates to the aggregate definition SUM(total_price) and adding it to the customer entity as a metric feature.

asset has to be related to our entity (see ).

For more information about using multiple join paths between an entity and a data asset, visit the page.

Specifies which asset time field to use in case of time-based aggregation is applied to the metric. If not specified, Lynk will use the asset's .

See for more information on how time fields are being used for time-based metric aggregations.

Measures are defined on a data asset level. See for in depth information on this.

Custom filters to be applied on the data asset. See page for in depth information on how to apply filters.

In case we have a many-to-one relationship between a Data Asset and an Entity, and we need to enrich the entity with some aggregation from the Data Asset - we can define which to enrich the entity by.

measure
related data asset
related data assets
default time_field
time aggregation
measures
filters
measure
Metric Feature Diagram