generated from dpguthrie/snowflake-dbt-demo-project
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from dpguthrie/neo-demo
spatial data
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{ | ||
config( | ||
materialized='table', | ||
post_hook='alter table {{ this }} add search optimization on geo(point_features);' | ||
) | ||
}} | ||
|
||
select | ||
|
||
-- https://docs.snowflake.com/en/sql-reference/functions/st_collect | ||
st_collect(point) as point_features | ||
from {{ ref('stg_bikes_station_info') }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
version: 2 | ||
|
||
|
||
sources: | ||
- name: bikes | ||
database: chicago_divvy_bike_station_status | ||
schema: public | ||
tables: | ||
- name: station_info_flatten | ||
columns: | ||
- name: station_id | ||
tests: | ||
- not_null | ||
- unique | ||
- name: lat | ||
tests: | ||
- dbt_utils.expression_is_true: | ||
expression: "lat between -90 and 90" | ||
- dbt_utils.expression_is_true: | ||
expression: "lon between -180 and 180" | ||
- name: station_status_flatten_full |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
with source as ( | ||
select * from {{ source('bikes', 'station_info_flatten') }} | ||
), | ||
|
||
recast as ( | ||
select | ||
short_name::varchar as short_name, | ||
station_type::varchar as station_type, | ||
name::varchar as name, | ||
electric_bike_surcharge_waiver, | ||
external_id::varchar as external_id, | ||
legacy_id::int as legacy_id, | ||
capacity, | ||
has_kiosk, | ||
station_id::varchar as station_id, | ||
region_id::int as region_id, | ||
eightd_station_services, | ||
lat as latitude, | ||
lon as longitude, | ||
|
||
-- https://docs.snowflake.com/en/sql-reference/functions/st_makepoint | ||
st_makepoint(lon, lat) as point | ||
from source | ||
) | ||
|
||
select * from recast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
with source as ( | ||
select * from {{ source('bikes', 'station_status_flatten_full') }} | ||
), | ||
|
||
recast as ( | ||
select | ||
station_id::varchar as station_id, | ||
station_status::varchar as station_status, | ||
num_ebikes_available, | ||
num_bikes_available, | ||
num_docks_available, | ||
num_docks_disabled, | ||
num_bikes_disabled, | ||
is_installed, | ||
num_ebikes_available_bool as is_ebikes_available, | ||
is_renting, | ||
is_returning, | ||
eightd_has_available_keys, | ||
legacy_id::varchar as legacy_id, | ||
last_updated, | ||
last_reported | ||
from source | ||
) | ||
|
||
select * from recast |