-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds deployer tables * fix playground * Add discovered deployers * lint fixes * more lint fixes * lint fixes * fix * fix * fix * lint fixes
- Loading branch information
Showing
8 changed files
with
178 additions
and
2 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,10 @@ | ||
sources: | ||
- name: ethereum | ||
|
||
database: bigquery-public-data | ||
|
||
schema: crypto_ethereum | ||
tables: | ||
- name: transactions | ||
identifier: transactions | ||
|
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 @@ | ||
sources: | ||
- name: optimism | ||
|
||
database: bigquery-public-data | ||
|
||
schema: goog_blockchain_optimism_mainnet_us | ||
tables: | ||
- name: transactions | ||
identifier: transactions | ||
|
||
- name: logs | ||
identifier: logs |
13 changes: 13 additions & 0 deletions
13
warehouse/dbt/models/playground/ethereum__transactions.sql
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,13 @@ | ||
{{ | ||
config( | ||
materialized='table', | ||
) if target.name in ['playground', 'dev'] else config( | ||
enabled=false, | ||
) | ||
}} | ||
SELECT * | ||
FROM {{ source("ethereum", 'transactions') }} | ||
WHERE block_timestamp >= TIMESTAMP_TRUNC( | ||
TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL -14 DAY), | ||
DAY | ||
) |
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,13 @@ | ||
{{ | ||
config( | ||
materialized='table', | ||
) if target.name in ['playground', 'dev'] else config( | ||
enabled=false, | ||
) | ||
}} | ||
SELECT * | ||
FROM {{ source("optimism", 'logs') }} | ||
WHERE block_timestamp >= TIMESTAMP_TRUNC( | ||
TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL -14 DAY), | ||
DAY | ||
) |
13 changes: 13 additions & 0 deletions
13
warehouse/dbt/models/playground/optimism__transactions.sql
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,13 @@ | ||
{{ | ||
config( | ||
materialized='table', | ||
) if target.name in ['playground', 'dev'] else config( | ||
enabled=false, | ||
) | ||
}} | ||
SELECT * | ||
FROM {{ source("optimism", 'transactions') }} | ||
WHERE block_timestamp >= TIMESTAMP_TRUNC( | ||
TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL -14 DAY), | ||
DAY | ||
) |
34 changes: 34 additions & 0 deletions
34
warehouse/dbt/models/staging/ethereum/stg_ethereum__deployers.sql
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,34 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
partition_by={ | ||
"field": "block_timestamp", | ||
"data_type": "timestamp", | ||
"granularity": "day", | ||
}, | ||
unique_id="transaction_hash", | ||
on_schema_change="append_new_columns", | ||
incremental_strategy="insert_overwrite" | ||
) if target.name == 'production' else config( | ||
materialized='table', | ||
) | ||
}} | ||
|
||
SELECT | ||
block_timestamp, | ||
`hash` AS transaction_hash, | ||
from_address AS deployer_address, | ||
receipt_contract_address AS contract_address | ||
FROM {{ source("ethereum", "transactions") }} | ||
WHERE | ||
to_address IS NULL | ||
AND receipt_status = 1 | ||
AND receipt_contract_address IS NOT NULL | ||
{% if is_incremental() %} | ||
WHERE | ||
TIMESTAMP_TRUNC(block_timestamp, DAY) >= ( | ||
SELECT TIMESTAMP_TRUNC(MAX(block_timestamp), DAY) | ||
FROM {{ this }} | ||
) | ||
AND TIMESTAMP_TRUNC(block_timestamp, DAY) < CURRENT_TIMESTAMP() | ||
{% endif %} |
49 changes: 49 additions & 0 deletions
49
warehouse/dbt/models/staging/optimism/stg_optimism__deployers.sql
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,49 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
partition_by={ | ||
"field": "block_timestamp", | ||
"data_type": "timestamp", | ||
"granularity": "day", | ||
}, | ||
unique_id="transaction_hash", | ||
on_schema_change="append_new_columns", | ||
incremental_strategy="insert_overwrite" | ||
) if target.name == 'production' else config( | ||
materialized='table', | ||
) | ||
}} | ||
WITH {% if is_incremental() %} max_block_timestamp AS ( | ||
SELECT TIMESTAMP_TRUNC(MAX(block_timestamp), DAY) | ||
FROM {{ this }} | ||
), | ||
{% endif %} | ||
logs AS ( | ||
-- transactions | ||
SELECT * | ||
FROM {{ oso_source("optimism", "logs") }} | ||
{% if is_incremental() %} | ||
WHERE | ||
TIMESTAMP_TRUNC(block_timestamp, DAY) >= ( | ||
SELECT * FROM max_block_timestamp | ||
) | ||
AND TIMESTAMP_TRUNC(block_timestamp, DAY) < CURRENT_TIMESTAMP() | ||
{% endif %} | ||
) | ||
|
||
SELECT | ||
t.block_timestamp AS block_timestamp, | ||
t.transaction_hash AS transaction_hash, | ||
t.from_address AS deployer_address, | ||
l.address AS contract_address | ||
FROM {{ oso_source("optimism", "transactions") }} AS t | ||
INNER JOIN logs AS l | ||
ON t.transaction_hash = l.transaction_hash | ||
WHERE | ||
t.to_address IS null | ||
{% if is_incremental() %} | ||
AND TIMESTAMP_TRUNC(block_timestamp, DAY) >= ( | ||
SELECT * FROM max_block_timestamp | ||
) | ||
AND TIMESTAMP_TRUNC(block_timestamp, DAY) < CURRENT_TIMESTAMP() | ||
{% endif %} |
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