Created
May 6, 2022 18:46
-
-
Save MikeRzhevsky/e5f818bf7961c92bcbf303d83ad98152 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
with t as (select date, | |
clientid, | |
arrayJoin(JSONExtract(assumeNotNull(hour_info),'Array(String)')) as hour, | |
arrayJoin(extractAll(assumeNotNull(productSku),'"(\\w+)"')) as product | |
from {{ ref("src_for_web_sessions") }}) | |
select CAST(t.date as Date) as "Дата", t.hour as "Час", item.`ссылка` as "Товар", count(*) as "Количество просмотров" from t | |
join (select * from {{source('bq','`cifra_товары`')}} ) as item on item.`код sku` = t.product | |
group by t.date, t.hour, item.`ссылка`, t.clientid | |
UNION ALL | |
select CAST(t.date as Date) as "Дата", t.hour as "Час", item.`ссылка` as "Товар", count(*) as "Количество просмотров" from t | |
join (select * from {{source('bq','`cifra_товары`')}} limit 1 by `код группы sku`) as item on item.`код группы sku` = t.product | |
group by t.date, t.hour, item.`ссылка`, t.clientid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment