I have a similar case and give a +1 that Looker creating the SQL for a customer dimensions seems buggy.
I have customer time dim that only does:
New dimension = coalesce(${some_date_1},${some_date_2},${some_date_3})
The explore is supposed to convert UTC to CEST. All dates are time group dims (with 1 and 2 being a DATE in the date base). All use (and should use) tz_convert.
If I use the dimensions standalone, the convert works as expected. But COALESCE over the 3 converts the dates to a time (with UTC to CEST adjustment, but coming from the DATE value) which is not expected:
The underlying sql does this which imho is interpreting the the convert when it should not be done (on dates):
…> > salesforce_opportunity.OPPORTUNITY_ID_C AS “salesforce_opportunity.opportunity_id_visible”,> (TO_CHAR(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.RELATION_MIN_GO_LIVE_DATE_C AS TIMESTAMP_NTZ))), ‘YYYY-MM-DD’)) AS “salesforce_opportunity.first_relation_go_live_date”,> (TO_CHAR(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.CUSTOMER_INTEGRATION_CURRENT_GO_LIVE AS TIMESTAMP_NTZ))), ‘YYYY-MM-DD’)) AS “so.customer_integration_current_go_live_date”,> (TO_CHAR(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.WON_TIME_C AS TIMESTAMP_NTZ))), ‘YYYY-MM-DD’)) AS “salesforce_opportunity.opportunity_won_date”,> (TO_CHAR(DATE_TRUNC(‘second’, CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.WON_TIME_C AS TIMESTAMP_NTZ))), ‘YYYY-MM-DD HH24:MI:SS’)) AS “salesforce_opportunity.opportunity_won_time”,> CASE WHEN TO_DATE(COALESCE((CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.RELATION_MIN_GO_LIVE_DATE_C AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))), (CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.CUSTOMER_INTEGRATION_CURRENT_GO_LIVE AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))), (CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.WON_TIME_C AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))))) = COALESCE((CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.RELATION_MIN_GO_LIVE_DATE_C AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))), (CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.CUSTOMER_INTEGRATION_CURRENT_GO_LIVE AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))), (CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.WON_TIME_C AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ)))) THEN TO_CHAR(COALESCE((CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.RELATION_MIN_GO_LIVE_DATE_C AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))), (CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.CUSTOMER_INTEGRATION_CURRENT_GO_LIVE AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))), (CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.WON_TIME_C AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ)))), ‘YYYY-MM-DD’) ELSE TO_CHAR(DATE_TRUNC(‘second’, COALESCE((CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.RELATION_MIN_GO_LIVE_DATE_C AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))), (CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.CUSTOMER_INTEGRATION_CURRENT_GO_LIVE AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))), (CONVERT_TIMEZONE(‘Europe/Berlin’, ‘UTC’, CAST(TO_DATE(CONVERT_TIMEZONE(‘UTC’, ‘Europe/Berlin’, CAST(salesforce_opportunity.WON_TIME_C AS TIMESTAMP_NTZ))) AS TIMESTAMP_NTZ))))), ‘YYYY-MM-DD HH24:MI:SS’) END> AS new_dimension,> > …