flow-models/models/silver/streamline/core/streamline__blocks.sql
Shah Newaz Khan d14843bd0c
Stream 98 fix nodeurl (#141)
* fixed node urls

* limited streamline_blocks to candidate node 7 root height

---------

Co-authored-by: shah <info@shahnewazkhan.ca>
2023-08-03 12:30:13 -07:00

24 lines
745 B
SQL

{{ config (
materialized = "view",
tags = ['streamline_view']
) }}
{% if execute %}
{% set height = run_query('SELECT streamline.udf_get_chainhead()') %}
{% set block_height = height.columns[0].values()[0] %}
{% else %}
{% set block_height = 0 %}
{% endif %}
SELECT
height as block_height,
node_url
FROM
TABLE(streamline.udtf_get_base_table({{block_height}}))
WHERE
block_height > 4132133 -- Root Height for Candidate node 7
-- the earliest available block we can ingest since earlier candidat nodes
-- do not have the get_block_by_height grpc method
-- https://developers.flow.com/concepts/nodes/node-operation/past-sporks#candidate-4