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

Transfomer - Fix JOIN in core vault views #97

Merged
merged 4 commits into from
Aug 13, 2024
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
2 changes: 1 addition & 1 deletion transformers/synthetix/.sqlfluff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[sqlfluff]
dialect = postgres
templater = jinja
ignore = templating
runaway_limit = 10
max_line_length = 80
indent_unit = space
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
{{
config(
materialized='table'
)
}}

WITH base AS (
SELECT
with base as (
select
block_number,
contract_address,
chain_id,
pool_id,
collateral_type,
CAST(
amount AS numeric
) AS amount,
CAST(
"value" AS numeric
) AS collateral_value
FROM
cast(
amount as numeric
) as amount,
cast(
value as numeric
) as collateral_value
from
{{ source(
'raw_arbitrum_mainnet',
"core_get_vault_collateral"
) }}
WHERE
amount IS NOT NULL
where
amount is not null
)
SELECT
blocks.ts,
base.block_number,

select
to_timestamp(blocks.timestamp) as ts,
cast(
blocks.block_number as integer
) as block_number,
base.contract_address,
CAST(
base.pool_id AS INTEGER
) AS pool_id,
CAST(
base.collateral_type AS VARCHAR
) AS collateral_type,
{{ convert_wei('base.amount') }} AS amount,
{{ convert_wei('base.collateral_value') }} AS collateral_value
FROM
cast(
base.pool_id as integer
) as pool_id,
cast(
base.collateral_type as varchar
) as collateral_type,
{{ convert_wei('base.amount') }} as amount,
{{ convert_wei('base.collateral_value') }} as collateral_value
from
base
JOIN {{ ref('blocks_arbitrum_mainnet') }} AS blocks
ON base.block_number = blocks.block_number
inner join {{ source('raw_arbitrum_mainnet', 'blocks_parquet') }} as blocks
on base.block_number = blocks.block_number
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
{{
config(
materialized='table'
)
}}

WITH base AS (
SELECT
with base as (
select
block_number,
contract_address,
chain_id,
pool_id,
collateral_type,
CAST(
value_1 AS numeric
) AS debt
FROM
cast(
value_1 as numeric
) as debt
from
{{ source(
'raw_arbitrum_mainnet',
"core_get_vault_debt"
) }}
WHERE
value_1 IS NOT NULL
where
value_1 is not null
)
SELECT
blocks.ts,
base.block_number,

select
to_timestamp(blocks.timestamp) as ts,
cast(
blocks.block_number as integer
) as block_number,
base.contract_address,
CAST(
base.pool_id AS INTEGER
) AS pool_id,
CAST(
base.collateral_type AS VARCHAR
) AS collateral_type,
{{ convert_wei('base.debt') }} AS debt
FROM
cast(
base.pool_id as integer
) as pool_id,
cast(
base.collateral_type as varchar
) as collateral_type,
{{ convert_wei('base.debt') }} as debt
from
base
JOIN {{ ref('blocks_arbitrum_mainnet') }} AS blocks
ON base.block_number = blocks.block_number
inner join {{ source('raw_arbitrum_mainnet', 'blocks_parquet') }} as blocks
on base.block_number = blocks.block_number
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
{{
config(
materialized='table'
)
}}

WITH base AS (
SELECT
with base as (
select
block_number,
contract_address,
chain_id,
pool_id,
collateral_type,
CAST(
amount AS numeric
) AS amount,
CAST(
"value" AS numeric
) AS collateral_value
FROM
cast(
amount as numeric
) as amount,
cast(
value as numeric
) as collateral_value
from
{{ source(
'raw_arbitrum_sepolia',
"core_get_vault_collateral"
) }}
WHERE
amount IS NOT NULL
where
amount is not null
)
SELECT
blocks.ts,
base.block_number,

select
to_timestamp(blocks.timestamp) as ts,
cast(
blocks.block_number as integer
) as block_number,
base.contract_address,
CAST(
base.pool_id AS INTEGER
) AS pool_id,
CAST(
base.collateral_type AS VARCHAR
) AS collateral_type,
{{ convert_wei('base.amount') }} AS amount,
{{ convert_wei('base.collateral_value') }} AS collateral_value
FROM
cast(
base.pool_id as integer
) as pool_id,
cast(
base.collateral_type as varchar
) as collateral_type,
{{ convert_wei('base.amount') }} as amount,
{{ convert_wei('base.collateral_value') }} as collateral_value
from
base
JOIN {{ ref('blocks_arbitrum_sepolia') }} AS blocks
ON base.block_number = blocks.block_number
inner join {{ source('raw_arbitrum_sepolia', 'blocks_parquet') }} as blocks
on base.block_number = blocks.block_number
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
{{
config(
materialized='table'
)
}}

WITH base AS (
SELECT
with base as (
select
block_number,
contract_address,
chain_id,
pool_id,
collateral_type,
CAST(
value_1 AS numeric
) AS debt
FROM
cast(
value_1 as numeric
) as debt
from
{{ source(
'raw_arbitrum_sepolia',
"core_get_vault_debt"
) }}
WHERE
value_1 IS NOT NULL
where
value_1 is not null
)
SELECT
blocks.ts,
base.block_number,

select
to_timestamp(blocks.timestamp) as ts,
cast(
blocks.block_number as integer
) as block_number,
base.contract_address,
CAST(
base.pool_id AS INTEGER
) AS pool_id,
CAST(
base.collateral_type AS VARCHAR
) AS collateral_type,
{{ convert_wei('base.debt') }} AS debt
FROM
cast(
base.pool_id as integer
) as pool_id,
cast(
base.collateral_type as varchar
) as collateral_type,
{{ convert_wei('base.debt') }} as debt
from
base
JOIN {{ ref('blocks_arbitrum_sepolia') }} AS blocks
ON base.block_number = blocks.block_number
inner join {{ source('raw_arbitrum_sepolia', 'blocks_parquet') }} as blocks
on base.block_number = blocks.block_number
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
{{
config(
materialized='table'
)
}}


WITH base AS (
SELECT
with base as (
select
block_number,
contract_address,
chain_id,
pool_id,
collateral_type,
CAST(
amount AS numeric
) AS amount,
CAST(
"value" AS numeric
) AS collateral_value
FROM
cast(
amount as numeric
) as amount,
cast(
value as numeric
) as collateral_value
from
{{ source(
'raw_base_mainnet',
"core_get_vault_collateral"
) }}
WHERE
amount IS NOT NULL
where
amount is not null
)
SELECT
blocks.ts,
base.block_number,

select
to_timestamp(blocks.timestamp) as ts,
cast(
blocks.block_number as integer
) as block_number,
base.contract_address,
CAST(
base.pool_id AS INTEGER
) AS pool_id,
CAST(
base.collateral_type AS VARCHAR
) AS collateral_type,
{{ convert_wei('base.amount') }} AS amount,
{{ convert_wei('base.collateral_value') }} AS collateral_value
FROM
cast(
base.pool_id as integer
) as pool_id,
cast(
base.collateral_type as varchar
) as collateral_type,
{{ convert_wei('base.amount') }} as amount,
{{ convert_wei('base.collateral_value') }} as collateral_value
from
base
JOIN {{ ref('blocks_base_mainnet') }} AS blocks
ON base.block_number = blocks.block_number
inner join {{ source('raw_base_mainnet', 'blocks_parquet') }} as blocks
on base.block_number = blocks.block_number
Loading
Loading