Skip to content

Commit

Permalink
add discrepent columns between gold and livequery
Browse files Browse the repository at this point in the history
  • Loading branch information
jensenity committed Oct 17, 2024
1 parent 5196c3e commit ad8d989
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 27 deletions.
8 changes: 4 additions & 4 deletions macros/evm/evm.yaml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@
- [block_height, INTEGER, The start block height to get the logs from]
- [to_latest, BOOLEAN, Whether to continue fetching logs until the latest block or not]
return_type:
- "TABLE(block_number INTEGER, block_timestamp TIMESTAMP_NTZ, tx_hash STRING, event_index INTEGER, contract_address STRING, contract_name STRING, event_name STRING, decoded_log OBJECT, full_decoded_log VARIANT, origin_function_signature STRING, origin_from_address STRING, origin_to_address STRING, topics VARIANT, data STRING, event_removed STRING, tx_status STRING, _log_id STRING, fact_event_logs_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)"
- "TABLE(block_number INTEGER, block_timestamp TIMESTAMP_NTZ, tx_hash STRING, event_index INTEGER, contract_address STRING, contract_name STRING, event_name STRING, decoded_log OBJECT, full_decoded_log VARIANT, fact_decoded_event_logs_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)"
options: |
NOT NULL
RETURNS NULL ON NULL INPUT
Expand All @@ -408,7 +408,7 @@
signature:
- [block_height, INTEGER, The start block height to get the transfers from]
- [to_latest, BOOLEAN, Whether to continue fetching transfers until the latest block or not]
return_type:
return_type:
- "TABLE(tx_hash STRING, block_number NUMBER, block_timestamp TIMESTAMP_NTZ(9), from_address STRING, to_address STRING, value FLOAT, value_precise_raw STRING, value_precise STRING, gas NUMBER, gas_used NUMBER, input STRING, output STRING, TYPE STRING, identifier STRING, DATA OBJECT, tx_status STRING, sub_traces NUMBER, trace_status STRING, error_reason STRING, trace_index NUMBER, fact_traces_id STRING, inserted_timestamp TIMESTAMP_NTZ(9), modified_timestamp TIMESTAMP_NTZ(9))"
options: |
NOT NULL
Expand All @@ -422,7 +422,7 @@
signature:
- [block_height, INTEGER, The start block height to get the transfers from]
- [to_latest, BOOLEAN, Whether to continue fetching transfers until the latest block or not]
return_type:
return_type:
- "TABLE(block_number NUMBER, block_timestamp TIMESTAMP_NTZ, block_hash STRING, tx_hash STRING, nonce NUMBER, POSITION NUMBER, origin_function_signature STRING, from_address STRING, to_address STRING, VALUE FLOAT, value_precise_raw STRING, value_precise STRING, tx_fee FLOAT, tx_fee_precise STRING, gas_price FLOAT, gas_limit NUMBER, gas_used NUMBER, cumulative_gas_used NUMBER, input_data STRING, status STRING, effective_gas_price FLOAT, max_fee_per_gas FLOAT, max_priority_fee_per_gas FLOAT, r STRING, s STRING, v STRING, tx_type NUMBER, chain_id NUMBER, blob_versioned_hashes ARRAY, max_fee_per_blob_gas NUMBER, blob_gas_used NUMBER, blob_gas_price NUMBER, fact_transactions_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)"
options: |
NOT NULL
Expand Down Expand Up @@ -452,7 +452,7 @@
- [to_latest, BOOLEAN, Whether to continue fetching transfers until the latest block or not]
- [ez_token_transfers_id, STRING, The topic of the token transfers to get]
return_type:
- "TABLE(block_number INTEGER, block_timestamp TIMESTAMP_NTZ, tx_hash STRING, event_index INTEGER, origin_funcion_signature STRING, origin_from_address STRING, origin_to_address STRING, contract_address STRING, from_address STRING, to_address STRING, raw_amount_precise STRING, raw_amount FLOAT, amount_precise FLOAT, amount FLOAT, amount_usd FLOAT, decimals INTEGER, symbol STRING, token_price FLOAT, has_decimal STRING, has_price STRING, ez_token_transfers_id STRING, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)"
- "TABLE(block_number INTEGER, block_timestamp TIMESTAMP_NTZ, tx_hash STRING, event_index INTEGER, origin_function_signature STRING, origin_from_address STRING, origin_to_address STRING, contract_address STRING, from_address STRING, to_address STRING, raw_amount_precise STRING, raw_amount FLOAT, amount_precise FLOAT, amount FLOAT, amount_usd FLOAT, decimals INTEGER, symbol STRING, token_price FLOAT, has_decimal STRING, has_price STRING, _log_id STRING, ez_token_transfers_id STRING, _inserted_timestamp TIMESTAMP_NTZ, inserted_timestamp TIMESTAMP_NTZ, modified_timestamp TIMESTAMP_NTZ)"
options: |
NOT NULL
RETURNS NULL ON NULL INPUT
Expand Down
40 changes: 17 additions & 23 deletions macros/evm/evm_live_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
SELECT
block_number,
{{ schema }}.udf_rpc(
'eth_getBlockByNumber',
'eth_getBlockByNumber',
[utils.udf_int_to_hex(block_number), true]) AS DATA
FROM
{{ table_name }}
Expand All @@ -51,7 +51,7 @@ SELECT
latest_block_height,
block_number,
{{ schema }}.udf_rpc(
'eth_getBlockReceipts',
'eth_getBlockReceipts',
[utils.udf_int_to_hex(block_number)]) AS result,
v.value AS DATA
FROM
Expand Down Expand Up @@ -460,15 +460,8 @@ SELECT
B.event_name,
B.decoded_flat AS decoded_log,
B.decoded_data AS full_decoded_log,
C.origin_function_signature,
C.origin_from_address,
C.origin_to_address,
C.topics,
C.DATA,
C.event_removed :: STRING AS event_removed,
C.tx_status,
_log_id,
md5(_log_id) AS fact_event_logs_id,
md5(_log_id) AS fact_decoded_event_logs_id,
SYSDATE() AS _inserted_timestamp,
SYSDATE() AS inserted_timestamp,
SYSDATE() AS modified_timestamp
FROM _flatten_logs AS B
Expand Down Expand Up @@ -508,15 +501,15 @@ WITH heights AS (
latest_block_height
from
table(generator(ROWCOUNT => 1000)),
heights
heights
qualify block_number between min_height and max_height
),
raw_receipts as (
SELECT
latest_block_height,
block_number,
{{ schema }}.udf_rpc(
'eth_getBlockReceipts',
'eth_getBlockReceipts',
[utils.udf_int_to_hex(block_number)]) AS result,
v.value as DATA
from
Expand All @@ -527,7 +520,7 @@ WITH heights AS (
SELECT
block_number,
{{ schema }}.udf_rpc(
'eth_getBlockByNumber',
'eth_getBlockByNumber',
[utils.udf_int_to_hex(block_number), true]) AS DATA
from
spine
Expand Down Expand Up @@ -662,7 +655,7 @@ WITH heights AS (
raw_txs A
left join blocks b on b.block_number = A.block_number
left join receipts as r on r.tx_hash = A.data :hash::STRING
)
)
SELECT
block_number,
block_timestamp,
Expand Down Expand Up @@ -741,15 +734,15 @@ WITH heights AS (
latest_block_height
from
table(generator(ROWCOUNT => 1000)),
heights
heights
qualify block_number between min_height and max_height
),
raw_receipts as (
SELECT
latest_block_height,
block_number,
{{ schema }}.udf_rpc(
'eth_getBlockReceipts',
'eth_getBlockReceipts',
[utils.udf_int_to_hex(block_number)]) AS result,
v.value as DATA
from
Expand All @@ -760,7 +753,7 @@ WITH heights AS (
SELECT
block_number,
{{ schema }}.udf_rpc(
'eth_getBlockByNumber',
'eth_getBlockByNumber',
[utils.udf_int_to_hex(block_number), true]) AS DATA
from
spine
Expand Down Expand Up @@ -905,7 +898,7 @@ WITH heights AS (
FROM spine s,
LATERAL FLATTEN(input => PARSE_JSON(
{{ schema }}.udf_rpc(
'debug_traceBlockByNumber',
'debug_traceBlockByNumber',
[utils.udf_int_to_hex(s.block_number), {'tracer': 'callTracer'}])
)) v
),
Expand Down Expand Up @@ -1249,6 +1242,7 @@ SELECT
WHEN price IS NULL THEN 'false'
ELSE 'true'
END AS has_price,
_log_id,
md5(
cast(
coalesce(
Expand Down Expand Up @@ -1305,15 +1299,15 @@ WITH heights AS (
latest_block_height
from
table(generator(ROWCOUNT => 1000)),
heights
heights
qualify block_number between min_height and max_height
),
raw_receipts as (
SELECT
latest_block_height,
block_number,
{{ schema }}.udf_rpc(
'eth_getBlockReceipts',
'eth_getBlockReceipts',
[utils.udf_int_to_hex(block_number)]) AS result,
v.value as DATA
from
Expand All @@ -1324,7 +1318,7 @@ WITH heights AS (
SELECT
block_number,
{{ schema }}.udf_rpc(
'eth_getBlockByNumber',
'eth_getBlockByNumber',
[utils.udf_int_to_hex(block_number), true]) AS DATA
from
spine
Expand Down Expand Up @@ -1469,7 +1463,7 @@ WITH heights AS (
FROM spine s,
LATERAL FLATTEN(input => PARSE_JSON(
{{ schema }}.udf_rpc(
'debug_traceBlockByNumber',
'debug_traceBlockByNumber',
[utils.udf_int_to_hex(s.block_number), {'tracer': 'callTracer'}])
)) v
),
Expand Down

0 comments on commit ad8d989

Please sign in to comment.