Knowledge Drop

How do I make a primary key for my dimension group (timestamp, date)?

  • 8 July 2021
  • 0 replies
  • 11 views

Userlevel 4

Last tested: May 11, 2020
 

Since a dimension group is a collection of dimensions, you can't make it a primary key. Instead, make a single dimension with one timeframe, and let that be your primary key.

So if you have:

dimension_group: created {

type: time

timeframes: [time, month, year]

sql: ${TABLE}.created_at ;;

}

 

Then you can add a new dimension:

dimension: created_pk {

type: string

hidden: yes

primary_key: yes

sql: ${created_time} ;;

}

 

Here we add hidden because created_time is already in the dimension group.

 

This content is subject to limited support.                

 

 


0 replies

Be the first to reply!

Reply