id and timestamp columns

This commit is contained in:
drethereum 2023-11-13 11:59:06 -07:00
parent 8670911772
commit 5526975ba9
4 changed files with 58 additions and 3 deletions

View File

@ -0,0 +1,16 @@
{{ config(
materialized = 'view',
persist_docs ={ "relation": true,
"columns": true }
) }}
SELECT
contract_address,
DATA AS abi,
abi_source,
bytecode,
abis_id AS dim_contract_abis_id,
inserted_timestamp,
modified_timestamp
FROM
{{ ref('silver__abis') }}

View File

@ -0,0 +1,19 @@
version: 2
models:
- name: core__dim_contract_abis
description: >
'This table contains the contract ABIs that we have sourced from Polygonscan, the community, or bytecode matched. This table is the source of ABIs used in the `core__ez_decoded_event_logs` and `core__fact_decoded_event_logs` tables.
We first try to source ABIs from Polygonscan. If we cannot find an ABI on Polygonscan, we will rely on user submissions. To add a contract to this table, please visit [here](https://science.flipsidecrypto.xyz/abi-requestor/).
If we are unable to locate an ABI for a contract from Polygonscan or the community, we will try to find an ABI to use by matching the contract bytecode to a known contract bytecode we do have an ABI for.'
columns:
- name: CONTRACT_ADDRESS
description: 'The address of the contract.'
- name: ABI
description: 'The JSON ABI for the contract.'
- name: ABI_SOURCE
description: 'The source of the ABI. This can be `Polygonscan`, `user_submitted`, or `bytecode_matched`.'
- name: BYTECODE
description: 'The deployed bytecode of the contract.'

View File

@ -1,6 +1,7 @@
{{ config (
materialized = "incremental",
unique_key = "contract_address",
merge_exclude_columns = ["inserted_timestamp"],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION on equality(contract_address)",
tags = ['abis']
) }}
@ -167,7 +168,13 @@ SELECT
p.abi_source,
p.discord_username,
p.abi_hash,
created_contract_input AS bytecode
created_contract_input AS bytecode,
{{ dbt_utils.generate_surrogate_key(
['contract_address']
) }} AS abis_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
priority_abis p
LEFT JOIN {{ ref('silver__created_contracts') }}

View File

@ -4,6 +4,7 @@
unique_key = ['block_number', 'event_index'],
cluster_by = "block_timestamp::date",
incremental_predicates = ["dynamic_range", "block_number"],
merge_exclude_columns = ["inserted_timestamp"],
post_hook = "ALTER TABLE {{ this }} ADD SEARCH OPTIMIZATION",
tags = ['decoded_logs2']
) }}
@ -207,7 +208,13 @@ SELECT
DATA,
event_removed,
tx_status,
is_pending
is_pending,
{{ dbt_utils.generate_surrogate_key(
['tx_hash','event_index']
) }} AS decoded_logs_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
new_records
@ -232,7 +239,13 @@ SELECT
DATA,
event_removed,
tx_status,
is_pending
is_pending,
{{ dbt_utils.generate_surrogate_key(
['tx_hash','event_index']
) }} AS decoded_logs_id,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp,
'{{ invocation_id }}' AS _invocation_id
FROM
missing_data
{% endif %}