mirror of
https://gitlab.com/cief-data/dbt_cloud.git
synced 2026-08-19 04:14:00 +00:00
Geocoder function working
This commit is contained in:
@@ -1,21 +1,13 @@
|
||||
-- This block of code returns the entire json
|
||||
-- select
|
||||
-- ADDRESS_LINE_ONE,
|
||||
-- ADDRESS_LINE_TWO,
|
||||
-- {{ address_to_coordinates( 'ADDRESS_LINE_ONE', 'ADDRESS_LINE_TWO', 'POSTCODE', 'DISTRICT_NAME', 'STATE_NAME' ) }} as output_1
|
||||
-- from {{ ref('test_address__mock_data') }};
|
||||
|
||||
-- This block of code returns the latitude, longitude, metadata, every data column
|
||||
-- Fix why this block return 289 rows instead of 17 rows?
|
||||
WITH json_data AS (
|
||||
SELECT PARSE_JSON( {{ address_to_coordinates( 'ADDRESS_LINE_ONE', 'ADDRESS_LINE_TWO', 'POSTCODE', 'DISTRICT_NAME', 'STATE_NAME' ) }} ) AS response
|
||||
WITH geocoded AS (
|
||||
SELECT
|
||||
*,
|
||||
PARSE_JSON( {{ address_to_coordinates( 'ADDRESS_LINE_ONE', 'ADDRESS_LINE_TWO', 'POSTCODE', 'DISTRICT_NAME', 'STATE_NAME' ) }} ) AS METADATA
|
||||
from {{ ref('test_address__mock_data') }}
|
||||
)
|
||||
|
||||
SELECT
|
||||
response[0]:geometry:location:lat::float AS LATITUDE,
|
||||
response[0]:geometry:location:lng::float AS LONGITUDE,
|
||||
response AS METADATA,
|
||||
t.*
|
||||
FROM json_data
|
||||
CROSS JOIN {{ ref('test_address__mock_data') }} AS t;
|
||||
METADATA[0]:geometry:location:lat::float AS LATITUDE,
|
||||
METADATA[0]:geometry:location:lng::float AS LONGITUDE,
|
||||
*
|
||||
FROM geocoded;
|
||||
|
||||
Reference in New Issue
Block a user