Skip to main content

Overview

The global semantics system in Oxy enables you to define semantic objects once and reuse them throughout your project. This reduces duplication, ensures consistency, and makes maintenance significantly easier.

Key Concepts

Global Definitions

Define reusable semantic objects in globals/semantics.yml:
globals/semantics.yml
entities:
  customer:
    name: customer
    type: primary
    description: Primary customer entity
    key: customer_id

dimensions:
  customer_id:
    name: customer_id
    type: number
    description: Unique customer identifier
    expr: customer_id
  
  email:
    name: email
    type: string
    description: Email address
    expr: email
  
  timestamp:
    name: timestamp
    type: datetime
    description: Timestamp of the event or record
    expr: timestamp

measures:
  total_orders:
    name: total_orders
    type: count
    description: Total number of orders

descriptions:
  shipping_address: "Shipping address for the order"
  order_status: "Current status of the order"

tables:
  orders: "orders"
  customers: "customers"

Inheritance

Use inherits_from to extend global definitions:
semantics/views/orders.view.yml
name: orders
datasource: local
table: "{{globals.semantics.tables.orders}}.csv"

entities:
  - name: customer
    inherits_from: globals.semantics.entities.customer
    # Inherits: type=primary, description, key

dimensions:
  - inherits_from: globals.semantics.dimensions.customer_id
    # Inherits all properties
  
  - name: order_status
    type: string
    description: "{{globals.semantics.descriptions.order_status}}"
    expr: status

measures:
  - inherits_from: globals.semantics.measures.total_orders

Property Merging

Child properties override parent properties:
# Global definition
dimensions:
  customer_id:
    name: customer_id
    type: number
    description: Unique customer identifier
    expr: customer_id
# View-specific override
dimensions:
  - name: customer_id
    inherits_from: globals.semantics.dimensions.customer_id
    description: Customer who placed this order  # Overrides
    # type and expr are inherited

Usage Patterns

In Semantic Views

Inherit entities, dimensions, and measures:
semantics/views/orders.view.yml
entities:
  - inherits_from: globals.semantics.entities.customer

dimensions:
  - inherits_from: globals.semantics.dimensions.customer_id
  - inherits_from: globals.semantics.dimensions.timestamp

measures:
  - inherits_from: globals.semantics.measures.total_orders

In semantics.yml

Inherit dimension properties while specifying unique target mappings:
semantics.yml
dimensions:
  - name: id_user
    inherits_from: globals.semantics.dimensions.user_id
    targets:
      - primary_database.dbt_prod_core.dim_users.id_user
      - primary_database.dbt_prod_core.fct_user_events.id_user
    # Inherits: type, description from global definition
  
  - name: email
    inherits_from: globals.semantics.dimensions.email
    targets:
      - primary_database.dbt_prod_core.dim_users.email
      - primary_database.dbt_prod_core.fct_typeform_leads.email
    # Inherits: type, description from global definition
This pattern avoids repeating the same dimension definition for each target mapping.

Template Variables

Reference global values using template syntax:
table: "{{globals.tables.orders}}.csv"
description: "{{globals.semantics.descriptions.shipping_address}}"

See Also