Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evm #9

Merged
merged 4 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 3 additions & 40 deletions models/bronze/bronze__tendermint_blocks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,17 @@
cluster_by = ['_inserted_timestamp::date'],
merge_update_columns = ["block_id"],
) }}

WITH meta AS (

SELECT
registered_on,
last_modified,
LEAST(
last_modified,
registered_on
) AS _inserted_timestamp,
file_name
FROM
TABLE(
information_schema.external_table_files(
table_name => '{{ source( "streamline", "tendermint_blocks") }}'
)
) A

{% if is_incremental() %}
WHERE
LEAST(
registered_on,
last_modified
) >= (
SELECT
COALESCE(MAX(_INSERTED_TIMESTAMP), '1970-01-01' :: DATE) max_INSERTED_TIMESTAMP
FROM
{{ this }})
)
{% else %}
)
{% endif %}

SELECT
value,
_partition_by_block_id,
block_number AS block_id,
DATA,
TO_TIMESTAMP(
m._inserted_timestamp
_inserted_timestamp
) AS _inserted_timestamp
FROM
{{ source(
'streamline',
'tendermint_blocks'
) }}
JOIN meta m
ON m.file_name = metadata$filename
{{ ref('bronze__streamline_FR_tendermint_blocks') }}

WHERE
DATA: error IS NULL

Expand Down
42 changes: 2 additions & 40 deletions models/bronze/bronze__tendermint_transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,17 @@
merge_update_columns = ["data", "_inserted_timestamp"],
) }}

WITH meta AS (

SELECT
registered_on,
last_modified,
LEAST(
last_modified,
registered_on
) AS _inserted_timestamp,
file_name
FROM
TABLE(
information_schema.external_table_files(
table_name => '{{ source( "streamline", "tendermint_transactions") }}'
)
) A

{% if is_incremental() %}
WHERE
LEAST(
registered_on,
last_modified
) >= (
SELECT
COALESCE(MAX(_INSERTED_TIMESTAMP), '1970-01-01' :: DATE) max_INSERTED_TIMESTAMP
FROM
{{ this }})
)
{% else %}
)
{% endif %}

SELECT
value,
_partition_by_block_id,
block_number as block_id,
value :data :hash :: STRING AS tx_id,
metadata,
DATA,
TO_TIMESTAMP(
m._inserted_timestamp
_inserted_timestamp
) AS _inserted_timestamp
FROM
{{ source(
'streamline',
'tendermint_transactions'
) }}
JOIN meta m
ON m.file_name = metadata$filename
{{ ref('bronze__streamline_FR_tendermint_transactions') }}
WHERE
DATA: error IS NULL qualify(ROW_NUMBER() over (PARTITION BY value :data :hash :: STRING
ORDER BY
Expand Down
5 changes: 3 additions & 2 deletions models/silver/silver__blocks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ FROM
WHERE
data [0] :error IS NULL
AND DATA :error IS NULL
AND DATA :result :block :header :chain_id :: STRING IS NOT NULL
AND DATA[0] :result :block :header :chain_id :: STRING IS NOT NULL
AND (DATA :result :block :header :chain_id :: STRING IS NOT NULL
OR DATA[0] :result :block :header :chain_id :: STRING IS NOT NULL)


{% if is_incremental() %}
AND _inserted_timestamp :: DATE >= (
Expand Down
19 changes: 9 additions & 10 deletions models/silver/silver__transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ WITH base_transactions AS (

SELECT
block_id,
t.value :hash :: STRING AS tx_id,
t.value :tx_result :codespace AS codespace,
t.value :tx_result :gas_used :: NUMBER AS gas_used,
t.value :tx_result :gas_wanted :: NUMBER AS gas_wanted,
tx_id,
data :tx_result :codespace AS codespace,
data :tx_result :gas_used :: NUMBER AS gas_used,
data :tx_result :gas_wanted :: NUMBER AS gas_wanted,
CASE
WHEN t.value :tx_result :code :: NUMBER = 0 THEN TRUE
WHEN data :tx_result :code :: NUMBER = 0 THEN TRUE
ELSE FALSE
END AS tx_succeeded,
t.value :tx_result :code :: NUMBER AS tx_code,
t.value :tx_result :events AS msgs,
t.value :tx_result :log :: STRING AS tx_log,
data :tx_result :code :: NUMBER AS tx_code,
data :tx_result :events AS msgs,
data :tx_result :log :: STRING AS tx_log,
_inserted_timestamp
FROM
{{ ref('bronze__tendermint_transactions') }},
TABLE(FLATTEN(DATA :result :txs)) t
{{ ref('bronze__tendermint_transactions') }}

{% if is_incremental() %}
WHERE
Expand Down