Question

BigQuery dimension group datetime datatype time timeframe issues

  • 18 November 2021
  • 4 replies
  • 37 views

We have a datetime dimension being read from BigQuery, the problem is on Looker it converts the time value to Zeros.

Is there anyone to retain the time value?

 

  dimension_group: placed_at_local {
type: time
datatype: date
timeframes: [
raw,
hour,
time,
date,
]
sql: ${TABLE}.placed_at_local ;;
}

 


4 replies

Try and cast the value to a TIMESTAMP @Raghad Awwad 

try this and let me know if it works. Mark as helpful if it does. @Raghad Awwad 

  dimension_group: placed_at_local {
type: time
datatype: date
timeframes: [
raw,
hour,
time,
date,
]
sql: CAST(${TABLE}.placed_at_local AS TIMESTAMP) ;;
}

 

Unfortunately @Kehinde, it didn’t work. It produced that same error that forced me to define the dimension as a datatime.

 

 

  dimension_group: placed_at_local {
type: time
datatype: datetime
timeframes: [
raw,
hour,
time,
date,
]
sql: CAST(${TABLE}.placed_at_local AS TIMESTAMP) ;;
}

or

dimension_group: placed_at_local {
type: time
datatype: timestamp
timeframes: [
raw,
hour,
time,
date,
]
sql: CAST(${TABLE}.placed_at_local AS TIMESTAMP) ;;
}

or

dimension_group: placed_at_local {
type: time
timeframes: [
raw,
hour,
time,
date,
]
sql: CAST(${TABLE}.placed_at_local AS TIMESTAMP) ;;
}

I see, you are have a data type mismatch, comparing datetime and date. try the above. (The second third preferably) let me know how it goes. @Raghad Awwad 

Reply