-
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.
- Loading branch information
Showing
8 changed files
with
103 additions
and
37 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,40 @@ | ||
{# | ||
Using goog_blockchain_* public tables, this discovers deployers on a given network. | ||
#} | ||
|
||
{% macro goog_blockchain_deployers(network_name) %} | ||
WITH {% if is_incremental() %} max_block_timestamp AS ( | ||
SELECT MAX(block_timestamp) | ||
FROM {{ this }} | ||
), | ||
{% endif %} | ||
logs AS ( | ||
-- transactions | ||
SELECT * | ||
FROM {{ oso_source(network_name, "logs") }} | ||
{% if is_incremental() %} | ||
WHERE | ||
block_timestamp >= ( | ||
SELECT * FROM max_block_timestamp | ||
) | ||
AND block_timestamp < TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY) | ||
{% 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(network_name, "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 t.block_timestamp >= ( | ||
SELECT * FROM max_block_timestamp | ||
) | ||
AND t.block_timestamp < TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), DAY) | ||
{% endif %} | ||
{% endmacro %} |
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: arbitrum | ||
|
||
database: bigquery-public-data | ||
|
||
schema: goog_blockchain_arbitrum_one_us | ||
tables: | ||
- name: transactions | ||
identifier: transactions | ||
|
||
- name: logs | ||
identifier: logs |
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("arbitrum", '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/arbitrum__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("arbitrum", 'transactions') }} | ||
WHERE block_timestamp >= TIMESTAMP_TRUNC( | ||
TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL -14 DAY), | ||
DAY | ||
) |
16 changes: 16 additions & 0 deletions
16
warehouse/dbt/models/staging/arbitrum/stg_arbitrum__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,16 @@ | ||
{{ | ||
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', | ||
) | ||
}} | ||
{{ goog_blockchain_deployers("arbitrum") }} |
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
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
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