-
Notifications
You must be signed in to change notification settings - Fork 0
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
18 changed files
with
300 additions
and
343 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
dbt run -s execution_power | ||
dbt run | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
dbt run -s execution_power | ||
dbt run | ||
|
||
|
||
|
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,14 @@ | ||
{% macro get_incremental_filter() %} | ||
{% if is_incremental() %} | ||
last_partition AS ( | ||
SELECT max(partition_month) as partition_month | ||
FROM {{ this }} | ||
), | ||
{% endif %} | ||
{% endmacro %} | ||
|
||
{% macro apply_incremental_filter(timestamp_field, add_and=false) %} | ||
{% if is_incremental() %} | ||
{{ "AND " if add_and else "WHERE "}}toStartOfMonth({{ timestamp_field }}) >= (SELECT partition_month FROM last_partition) | ||
{% endif %} | ||
{% endmacro %} |
35 changes: 35 additions & 0 deletions
35
models/consensus/attestations/metrics/consensus_atts_inclusion_distance.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,35 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
incremental_strategy='delete+insert', | ||
engine='ReplacingMergeTree()', | ||
order_by='(day, inc_dist_cohort)', | ||
unique_key='(day, inc_dist_cohort)', | ||
partition_by='partition_month' | ||
) | ||
}} | ||
|
||
WITH | ||
|
||
{{ get_incremental_filter() }} | ||
|
||
|
||
inclusion_distance AS ( | ||
SELECT | ||
toDate({{ compute_timestamp_at_slot('f_inclusion_slot') }}) AS day | ||
,f_inclusion_slot - f_slot AS inc_dist_cohort | ||
,COUNT(*) AS cnt | ||
FROM {{ get_postgres('chaind', 't_attestations') }} | ||
{{ apply_incremental_filter(compute_timestamp_at_slot('f_inclusion_slot')) }} | ||
GROUP BY 1,2 | ||
) | ||
|
||
SELECT | ||
toStartOfMonth(day) AS partition_month | ||
,day | ||
,inc_dist_cohort | ||
,cnt | ||
FROM | ||
inclusion_distance | ||
WHERE | ||
day < (SELECT MAX(day) FROM inclusion_distance) |
28 changes: 0 additions & 28 deletions
28
models/consensus/attestations/metrics/consensus_atts_inclusion_distance_d.sql
This file was deleted.
Oops, something went wrong.
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
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
37 changes: 23 additions & 14 deletions
37
models/consensus/blocks/transformations/consensus_blocks_graffiti.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 |
---|---|---|
@@ -1,28 +1,37 @@ | ||
{{ | ||
config( | ||
materialized='incremental', | ||
incremental_strategy='delete+insert', | ||
config( | ||
materialized='incremental', | ||
incremental_strategy='delete+insert', | ||
engine='ReplacingMergeTree()', | ||
order_by='(day, graffiti, f_proposer_index)', | ||
primary_key='(day, graffiti, f_proposer_index)', | ||
partition_by='partition_month' | ||
) | ||
unique_key='(day, graffiti, f_proposer_index)', | ||
partition_by='partition_month' | ||
) | ||
}} | ||
|
||
WITH | ||
|
||
WITH blocks_graffiti AS ( | ||
{{ get_incremental_filter() }} | ||
|
||
blocks_graffiti AS ( | ||
SELECT | ||
toStartOfMonth({{ compute_timestamp_at_slot('f_slot') }}) AS partition_month | ||
,toDate({{ compute_timestamp_at_slot('f_slot') }}) AS day | ||
toDate({{ compute_timestamp_at_slot('f_slot') }}) AS day | ||
,f_proposer_index | ||
,{{ decode_graffiti('f_graffiti') }} AS graffiti | ||
,COUNT(*) AS cnt | ||
FROM | ||
{{ get_postgres('chaind', 't_blocks') }} | ||
{% if is_incremental() %} | ||
WHERE toStartOfMonth({{ compute_timestamp_at_slot('f_slot') }}) >= (SELECT max(partition_month) FROM {{ this }}) | ||
{% endif %} | ||
GROUP BY 1, 2, 3, 4 | ||
{{ apply_incremental_filter(compute_timestamp_at_slot('f_slot')) }} | ||
GROUP BY 1, 2, 3 | ||
) | ||
|
||
SELECT * FROM blocks_graffiti | ||
SELECT | ||
toStartOfMonth(day) AS partition_month | ||
,day | ||
,f_proposer_index | ||
,graffiti | ||
,cnt | ||
FROM | ||
blocks_graffiti | ||
WHERE | ||
day < (SELECT MAX(day) FROM blocks_graffiti) |
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
Oops, something went wrong.