Skip to content

Commit b0dda32

Browse files
committed
join on ilike not '='
1 parent c1286b9 commit b0dda32

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

my_dbt_project/models/dashboards/core_query_thematics_keywords.sql

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{{ config(
2-
materialized='incremental'
3-
,unique_key=['week','channel_title']
2+
materialized='incremental',
3+
unique_key=['week','channel_title'],
4+
on_schema_change='append_new_columns'
45
)
56
}}
67

@@ -18,7 +19,6 @@ WITH program_durations AS (
1819
FROM public.program_metadata pm
1920
WHERE pm.country = 'france'
2021
),
21-
2222
program_weeks AS (
2323
SELECT
2424
pd.channel_title,
@@ -32,7 +32,6 @@ program_weeks AS (
3232
)::date AS week_start
3333
FROM program_durations pd
3434
),
35-
3635
program_airings AS (
3736
SELECT
3837
channel_title,
@@ -43,7 +42,6 @@ program_airings AS (
4342
week_start
4443
FROM program_weeks
4544
),
46-
4745
weekly_program_durations AS (
4846
SELECT
4947
channel_title,
@@ -52,7 +50,6 @@ weekly_program_durations AS (
5250
FROM program_airings
5351
GROUP BY channel_title, week_start
5452
),
55-
5653
keyword_occurrences AS (
5754
SELECT DISTINCT
5855
COALESCE(pm.channel_title, k.channel_title) AS channel_title,
@@ -92,8 +89,6 @@ keyword_occurrences AS (
9289
LOWER(kw ->> 'theme') NOT LIKE '%indirect%'
9390
AND k.country = 'france'
9491
)
95-
96-
9792
SELECT
9893
ko.channel_title,
9994
ko.week,
@@ -121,11 +116,10 @@ SELECT
121116
FROM keyword_occurrences ko
122117
LEFT JOIN public.dictionary d
123118
ON d.keyword = ko.keyword AND d.theme LIKE ko.theme || '%' -- ensure matc with indirect theme inside the dictionary table
124-
125119
LEFT JOIN weekly_program_durations wpd
126120
ON wpd.channel_title = ko.channel_title AND wpd.week = ko.week
127121
LEFT JOIN public.keyword_macro_category kmc
128-
ON kmc.keyword = ko.keyword
122+
ON kmc.keyword ilike ko.keyword
129123
GROUP BY
130124
ko.channel_title,
131125
ko.week,

0 commit comments

Comments
 (0)