mirror of
https://gitlab.com/cief-data/dbt_cloud.git
synced 2026-08-19 04:14:00 +00:00
geocode external function define
This commit is contained in:
@@ -1,5 +1,19 @@
|
||||
select
|
||||
company_address_id,
|
||||
district_id,
|
||||
{{ address_to_coordinates( 'company_address_id', 'district_id' ) }} as output_1
|
||||
from {{ ref('test_address__mock_data') }};
|
||||
-- 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
|
||||
WITH json_data AS (
|
||||
SELECT PARSE_JSON( {{ address_to_coordinates( 'ADDRESS_LINE_ONE', 'ADDRESS_LINE_TWO', 'POSTCODE', 'DISTRICT_NAME', 'STATE_NAME' ) }} ) AS response
|
||||
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;
|
||||
@@ -1,5 +1,5 @@
|
||||
-- Macro to call EUDF stored in snowflake
|
||||
-- id, created_datetime, updated_datetime, reference, address_1, address_2, postcode, district, state, country
|
||||
{%- macro address_to_coordinates(column1, column2) -%}
|
||||
GLOBAL_FUNCTION.EUDF.ECHO_ADDRESS_TO_COORDINATES({{column1}}, {{column2}})
|
||||
{%- macro address_to_coordinates(column1, column2, column3, column4, column5) -%}
|
||||
GLOBAL_FUNCTION.EUDF.ECHO_ADDRESS_TO_COORDINATES({{column1}}, {{column2}}, {{column3}}, {{column4}}, {{column5}})
|
||||
{%- endmacro -%}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
select
|
||||
company_address_id,
|
||||
echo_address_to_coordinates(company_address_id, district_name)
|
||||
from {{ ref('test_address__mock_data') }}
|
||||
Reference in New Issue
Block a user