remove macros, add target db, update sl blocks

This commit is contained in:
tarikceric 2024-11-19 15:43:43 -08:00
parent d91b3eb152
commit ec3ded7f81
7 changed files with 13 additions and 67 deletions

View File

@ -2,9 +2,6 @@
{% if var("UPDATE_UDFS_AND_SPS") %}
{% set sql %}
CREATE schema if NOT EXISTS silver;
{{ create_udtf_get_base_table(
schema = "streamline"
) }}
{{ create_udf_bulk_rest_api_v2() }}
{% endset %}
{% do run_query(sql) %}

View File

@ -1,22 +0,0 @@
{% macro create_udtf_get_base_table(schema) %}
CREATE
OR REPLACE FUNCTION {{ schema }}.udtf_get_base_table(
max_height INTEGER
) returns TABLE (
height NUMBER
) AS $$ WITH base AS (
SELECT
ROW_NUMBER() over (
ORDER BY
SEQ4()
) AS id
FROM
TABLE(GENERATOR(rowcount => 100000000))
)
SELECT
id AS height
FROM
base
WHERE
id <= max_height $$;
{% endmacro %}

View File

@ -1,21 +0,0 @@
{% macro create_aws_aptos_api() %}
{{ log(
"Creating integration for target:" ~ target
) }}
{% if target.name == "prod" %}
{% set sql %}
CREATE api integration IF NOT EXISTS aws_aptos_api api_provider = aws_api_gateway api_aws_role_arn = 'arn:aws:iam::490041342817:role/aptos-api-prod-rolesnowflakeudfsAF733095-wEyotLQyFEIl' api_allowed_prefixes = (
'https://dedvhh9fi1.execute-api.us-east-1.amazonaws.com/prod/'
) enabled = TRUE;
{% endset %}
{% do run_query(sql) %}
{% elif target.name == "dev" %}
{% set sql %}
CREATE api integration IF NOT EXISTS aws_aptos_api_dev api_provider = aws_api_gateway api_aws_role_arn = 'arn:aws:iam::704693948482:role/aptos-api-stg-rolesnowflakeudfsAF733095-k23uBmqxZRsN' api_allowed_prefixes = (
'https://9v6g64rv1e.execute-api.us-east-1.amazonaws.com/stg/'
) enabled = TRUE;
{% endset %}
{% do run_query(sql) %}
{% endif %}
{% endmacro %}

View File

@ -4,10 +4,11 @@
func = 'streamline.udf_bulk_rest_api_v2',
target = "{{this.schema}}.{{this.identifier}}",
params ={ "external_table" :"blocks_tx_v2",
"sql_limit" :"1200000",
"sql_limit" :"10",
"producer_batch_size" :"300000",
"worker_batch_size" :"50000",
"sql_source" :"{{this.identifier}}" }
"sql_source" :"{{this.identifier}}",
"order_by_column": "block_number" }
),
tags = ['streamline_core_realtime']
) }}
@ -22,13 +23,6 @@ WITH blocks AS (
block_number
FROM
{{ ref("streamline__complete_blocks_tx") }}
WHERE
block_number < 252143860
EXCEPT
SELECT
block_number
FROM
{{ ref("streamline__complete_blocks_tx") }}
)
SELECT
ROUND(
@ -36,7 +30,7 @@ SELECT
-3
) :: INT AS partition_key,
block_number,
aptos_dev.live.udf_api(
{{ target.database }}.live.udf_api(
'GET',
'{service}/{Authentication}/v1/blocks/by_height/' || block_number || '?with_transactions=true',
object_construct(
@ -49,7 +43,4 @@ SELECT
'Vault/prod/aptos/node/mainnet'
) AS request
FROM
blocks
ORDER BY
block_number
limit 10
blocks

View File

@ -8,7 +8,8 @@
"sql_limit": "1200000",
"producer_batch_size": "300000",
"worker_batch_size": "50000",
"sql_source": "{{this.identifier}}" }
"sql_source": "{{this.identifier}}",
"order_by_column": "block_number" }
),
tags = ['streamline_core_realtime']
) }}
@ -72,7 +73,7 @@ SELECT
block_number,
-3
) :: INT AS partition_key,
aptos_dev.live.udf_api(
{{ target.database }}.live.udf_api(
'GET',
'{service}/{Authentication}/v1/transactions?start=' || tx_version || '&limit=100',
object_construct(
@ -86,6 +87,3 @@ SELECT
) AS request
FROM
work
ORDER BY
block_number
limit 10

View File

@ -16,4 +16,7 @@ WHERE
MAX(block_number)
FROM
{{ ref('streamline__chainhead') }}
)
)
UNION ALL
SELECT
0 AS block_number

View File

@ -4,7 +4,7 @@
) }}
SELECT
aptos.live.udf_api(
{{ target.database }}.live.udf_api(
'GET',
'{service}/{Authentication}/v1',
OBJECT_CONSTRUCT(