mirror of
https://gitlab.com/cief-data/dbt_cloud.git
synced 2026-08-19 04:14:00 +00:00
lee - snowpark_geolocator modified
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# DBT governance
|
||||
Thid markdown document will specify the rules that need to follow by every developer.
|
||||
This markdown document will specify the rules that need to follow by every developer.
|
||||
<br>
|
||||
Short naming converntion lists that need to follow
|
||||
Short naming convention lists that need to follow
|
||||
|
||||
| model_type Shortcut | Full name |
|
||||
| ------------------- | ------ |
|
||||
|
||||
@@ -1,6 +1,29 @@
|
||||
# snowpark start here
|
||||
def model(dbt, session):
|
||||
# Import libraries
|
||||
# Basic Snowpark API available
|
||||
# https://docs.snowflake.com/developer-guide/snowpark/reference/python/index.html
|
||||
from snowflake import *
|
||||
from geopy.geocoders import Nominatim
|
||||
import requests
|
||||
|
||||
my_sql_model_df = dbt.ref("test_address__mock_data")
|
||||
# Initialize geopy geolocator using Nominatim (OpenStreetMap)
|
||||
geolocator = Nominatim(user_agent="cief_geolocator")
|
||||
|
||||
# Function to geocode address and return latitude and longitude
|
||||
def geocode_address(address):
|
||||
location = geolocator.geocode(address)
|
||||
if location:
|
||||
return (location.latitude, location.longitude)
|
||||
else:
|
||||
return (None, None)
|
||||
|
||||
def model(dbt, session):
|
||||
|
||||
return my_sql_model_df
|
||||
# Database reference
|
||||
my_sql_model_df = dbt.ref("test_address__mock_data")
|
||||
address = 'selayang mall'
|
||||
|
||||
url = 'https://nominatim.openstreetmap.org/search/' + requests.utils.quote(address) + '?format=json'
|
||||
response = requests.get(url).json()
|
||||
|
||||
return url
|
||||
|
||||
|
||||
Reference in New Issue
Block a user