From d74c0dc29fae8d02140e892cec2f83e71b95c2ff Mon Sep 17 00:00:00 2001 From: austinFlipside <93135983+austinFlipside@users.noreply.github.com> Date: Tue, 8 Feb 2022 21:13:39 -0500 Subject: [PATCH] An 690/new eth data (#1) * new dbt eth project * new eth data * yml changes * updates * path updates * update sources --- README.md | 17 ++++++- analysis/.gitkeep | 0 data/.gitkeep | 0 dbt_project.yml | 47 +++++++++++++++++++ macros/.gitkeep | 0 .../bronze/bronze_ethereum_2022__blocks.sql | 20 ++++++++ models/example/my_first_dbt_model.sql | 27 +++++++++++ models/example/my_second_dbt_model.sql | 6 +++ models/example/schema.yml | 21 +++++++++ models/sources.yml | 9 ++++ snapshots/.gitkeep | 0 tests/.gitkeep | 0 12 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 analysis/.gitkeep create mode 100644 data/.gitkeep create mode 100644 dbt_project.yml create mode 100644 macros/.gitkeep create mode 100644 models/bronze/bronze_ethereum_2022__blocks.sql create mode 100644 models/example/my_first_dbt_model.sql create mode 100644 models/example/my_second_dbt_model.sql create mode 100644 models/example/schema.yml create mode 100644 models/sources.yml create mode 100644 snapshots/.gitkeep create mode 100644 tests/.gitkeep diff --git a/README.md b/README.md index 11f18637..7874ac84 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ -# ethereum-models -Ethereum Facelift 2022 +Welcome to your new dbt project! + +### Using the starter project + +Try running the following commands: +- dbt run +- dbt test + + +### Resources: +- Learn more about dbt [in the docs](https://docs.getdbt.com/docs/introduction) +- Check out [Discourse](https://discourse.getdbt.com/) for commonly asked questions and answers +- Join the [chat](https://community.getdbt.com/) on Slack for live discussions and support +- Find [dbt events](https://events.getdbt.com) near you +- Check out [the blog](https://blog.getdbt.com/) for the latest news on dbt's development and best practices diff --git a/analysis/.gitkeep b/analysis/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/dbt_project.yml b/dbt_project.yml new file mode 100644 index 00000000..2f9c9f52 --- /dev/null +++ b/dbt_project.yml @@ -0,0 +1,47 @@ + +# Name your project! Project names should contain only lowercase characters +# and underscores. A good package name should reflect your organization's +# name or the intended use of these models +name: 'ethereum_models' +version: '1.0.0' +config-version: 2 + +# This setting configures which "profile" dbt uses for this project. +profile: 'snowflake' + +# These configurations specify where dbt should look for different types of files. +# The `source-paths` config, for example, states that models in this project can be +# found in the "models/" directory. You probably won't need to change these! +source-paths: ["models"] +analysis-paths: ["analysis"] +test-paths: ["tests"] +data-paths: ["data"] +macro-paths: ["macros"] +snapshot-paths: ["snapshots"] + +target-path: "target" # directory which will store compiled SQL files +clean-targets: # directories to be removed by `dbt clean` + - "target" + - "dbt_modules" + + +# Configuring models +# Full documentation: https://docs.getdbt.com/docs/configuring-models + +# In this example config, we tell dbt to build all models in the example/ directory +# as tables. These settings can be overridden in the individual model files +# using the `{{ config(...) }}` macro. +models: + +copy_grants: true + sql_models: + ethereum: + materialized: incremental + +schema: ethereum + +tags: ethereum + flow: + materialized: incremental + +schema: flow + +tags: flow + +vars: + "dbt_date:time_zone": America/Los_Angeles diff --git a/macros/.gitkeep b/macros/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/models/bronze/bronze_ethereum_2022__blocks.sql b/models/bronze/bronze_ethereum_2022__blocks.sql new file mode 100644 index 00000000..aaadf0fa --- /dev/null +++ b/models/bronze/bronze_ethereum_2022__blocks.sql @@ -0,0 +1,20 @@ +{{ config ( + materialized = 'view', + tags = ['snowflake', 'ethereum', 'bronze_ethereum', 'ethereum_blocks'] +) }} + +SELECT + record_id, + offset_id, + block_id, + block_timestamp, + network, + chain_id, + tx_count, + header, + ingested_at +FROM + {{ source( + 'prod', + 'ethereum_blocks' + ) }} diff --git a/models/example/my_first_dbt_model.sql b/models/example/my_first_dbt_model.sql new file mode 100644 index 00000000..f31a12d9 --- /dev/null +++ b/models/example/my_first_dbt_model.sql @@ -0,0 +1,27 @@ + +/* + Welcome to your first dbt model! + Did you know that you can also configure models directly within SQL files? + This will override configurations stated in dbt_project.yml + + Try changing "table" to "view" below +*/ + +{{ config(materialized='table') }} + +with source_data as ( + + select 1 as id + union all + select null as id + +) + +select * +from source_data + +/* + Uncomment the line below to remove records with null `id` values +*/ + +-- where id is not null diff --git a/models/example/my_second_dbt_model.sql b/models/example/my_second_dbt_model.sql new file mode 100644 index 00000000..c91f8793 --- /dev/null +++ b/models/example/my_second_dbt_model.sql @@ -0,0 +1,6 @@ + +-- Use the `ref` function to select from other models + +select * +from {{ ref('my_first_dbt_model') }} +where id = 1 diff --git a/models/example/schema.yml b/models/example/schema.yml new file mode 100644 index 00000000..2a530817 --- /dev/null +++ b/models/example/schema.yml @@ -0,0 +1,21 @@ + +version: 2 + +models: + - name: my_first_dbt_model + description: "A starter dbt model" + columns: + - name: id + description: "The primary key for this table" + tests: + - unique + - not_null + + - name: my_second_dbt_model + description: "A starter dbt model" + columns: + - name: id + description: "The primary key for this table" + tests: + - unique + - not_null diff --git a/models/sources.yml b/models/sources.yml new file mode 100644 index 00000000..0d10d692 --- /dev/null +++ b/models/sources.yml @@ -0,0 +1,9 @@ +version: 2 + +sources: + - name: prod + database: chainwalkers + schema: prod + tables: + - name: ethereum_blocks + - name: ethereum_txs diff --git a/snapshots/.gitkeep b/snapshots/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tests/.gitkeep b/tests/.gitkeep new file mode 100644 index 00000000..e69de29b