feat(transform): add country_name_en + country_slug to dim_cities, pass through city_market_profile
Prerequisite for all pSEO serving models. Adds CASE-based country_name_en and URL-safe country_slug to foundation.dim_cities, then selects them through serving.city_market_profile so downstream models inherit them automatically. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -55,6 +55,56 @@ SELECT
|
|||||||
LOWER(REGEXP_REPLACE(
|
LOWER(REGEXP_REPLACE(
|
||||||
COALESCE(vc.city, ec.city_slug_raw), '[^a-z0-9]+', '-'
|
COALESCE(vc.city, ec.city_slug_raw), '[^a-z0-9]+', '-'
|
||||||
)) AS city_slug,
|
)) AS city_slug,
|
||||||
|
-- Human-readable country name for pSEO templates and internal linking
|
||||||
|
CASE ec.country_code
|
||||||
|
WHEN 'DE' THEN 'Germany'
|
||||||
|
WHEN 'ES' THEN 'Spain'
|
||||||
|
WHEN 'GB' THEN 'United Kingdom'
|
||||||
|
WHEN 'FR' THEN 'France'
|
||||||
|
WHEN 'IT' THEN 'Italy'
|
||||||
|
WHEN 'PT' THEN 'Portugal'
|
||||||
|
WHEN 'AT' THEN 'Austria'
|
||||||
|
WHEN 'CH' THEN 'Switzerland'
|
||||||
|
WHEN 'NL' THEN 'Netherlands'
|
||||||
|
WHEN 'BE' THEN 'Belgium'
|
||||||
|
WHEN 'SE' THEN 'Sweden'
|
||||||
|
WHEN 'NO' THEN 'Norway'
|
||||||
|
WHEN 'DK' THEN 'Denmark'
|
||||||
|
WHEN 'FI' THEN 'Finland'
|
||||||
|
WHEN 'US' THEN 'United States'
|
||||||
|
WHEN 'AR' THEN 'Argentina'
|
||||||
|
WHEN 'MX' THEN 'Mexico'
|
||||||
|
WHEN 'AE' THEN 'UAE'
|
||||||
|
WHEN 'AU' THEN 'Australia'
|
||||||
|
WHEN 'IE' THEN 'Ireland'
|
||||||
|
ELSE ec.country_code
|
||||||
|
END AS country_name_en,
|
||||||
|
-- URL-safe country slug derived from country_name_en
|
||||||
|
LOWER(REGEXP_REPLACE(
|
||||||
|
CASE ec.country_code
|
||||||
|
WHEN 'DE' THEN 'Germany'
|
||||||
|
WHEN 'ES' THEN 'Spain'
|
||||||
|
WHEN 'GB' THEN 'United Kingdom'
|
||||||
|
WHEN 'FR' THEN 'France'
|
||||||
|
WHEN 'IT' THEN 'Italy'
|
||||||
|
WHEN 'PT' THEN 'Portugal'
|
||||||
|
WHEN 'AT' THEN 'Austria'
|
||||||
|
WHEN 'CH' THEN 'Switzerland'
|
||||||
|
WHEN 'NL' THEN 'Netherlands'
|
||||||
|
WHEN 'BE' THEN 'Belgium'
|
||||||
|
WHEN 'SE' THEN 'Sweden'
|
||||||
|
WHEN 'NO' THEN 'Norway'
|
||||||
|
WHEN 'DK' THEN 'Denmark'
|
||||||
|
WHEN 'FI' THEN 'Finland'
|
||||||
|
WHEN 'US' THEN 'United States'
|
||||||
|
WHEN 'AR' THEN 'Argentina'
|
||||||
|
WHEN 'MX' THEN 'Mexico'
|
||||||
|
WHEN 'AE' THEN 'UAE'
|
||||||
|
WHEN 'AU' THEN 'Australia'
|
||||||
|
WHEN 'IE' THEN 'Ireland'
|
||||||
|
ELSE ec.country_code
|
||||||
|
END, '[^a-zA-Z0-9]+', '-'
|
||||||
|
)) AS country_slug,
|
||||||
COALESCE(vc.centroid_lat, 0::DOUBLE) AS lat,
|
COALESCE(vc.centroid_lat, 0::DOUBLE) AS lat,
|
||||||
COALESCE(vc.centroid_lon, 0::DOUBLE) AS lon,
|
COALESCE(vc.centroid_lon, 0::DOUBLE) AS lon,
|
||||||
ec.population,
|
ec.population,
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ WITH base AS (
|
|||||||
SELECT
|
SELECT
|
||||||
c.city_code,
|
c.city_code,
|
||||||
c.country_code,
|
c.country_code,
|
||||||
|
c.country_name_en,
|
||||||
|
c.country_slug,
|
||||||
c.city_name,
|
c.city_name,
|
||||||
c.city_slug,
|
c.city_slug,
|
||||||
c.lat,
|
c.lat,
|
||||||
@@ -55,6 +57,8 @@ scored AS (
|
|||||||
SELECT
|
SELECT
|
||||||
s.city_code,
|
s.city_code,
|
||||||
s.country_code,
|
s.country_code,
|
||||||
|
s.country_name_en,
|
||||||
|
s.country_slug,
|
||||||
s.city_name,
|
s.city_name,
|
||||||
s.city_slug,
|
s.city_slug,
|
||||||
s.lat,
|
s.lat,
|
||||||
|
|||||||
Reference in New Issue
Block a user