Last active
August 24, 2023 18:59
-
-
Save WouterNieuwerth/e2d2aef4d3e149ccac11bd237640941b to your computer and use it in GitHub Desktop.
Example SQL with incremental tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config { | |
type: "incremental", | |
description: "Counts the amount of specific events per session per day.", | |
schema: "monitoring", | |
tags: ["ga4"], | |
bigquery: { | |
partitionBy: "event_date", | |
} | |
} | |
select | |
CAST(event_date AS DATE FORMAT 'YYYYMMDD') as event_date, | |
count(distinct concat(user_pseudo_id,(select value.int_value from unnest(event_params) where key = 'ga_session_id'))) as value | |
from | |
${ when (incremental(), ref(dataform.projectConfig.vars.GA4_TABLE))} | |
${ when(!incremental(), `\`${constants.GA4_DATABASE}.${constants.GA4_DATASET}.events_*\``) } | |
${ when(!incremental(), "where contains_substr(_TABLE_SUFFIX, 'intraday') is not true") } | |
group by | |
event_date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment