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

Transformers - Lint Models #102

Merged
merged 7 commits into from
Aug 27, 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
6 changes: 5 additions & 1 deletion transformers/synthetix/.sqlfluff
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ignore = templating
runaway_limit = 10
max_line_length = 80
indent_unit = space
exclude_rules = ST06, ST05

[sqlfluff:indentation]
tab_space_size = 4
Expand Down Expand Up @@ -34,4 +35,7 @@ capitalisation_policy = lower
capitalisation_policy = lower

[sqlfluff:rules:ambiguous.column_references] # Number in group by
group_by_and_order_by_style = implicit
group_by_and_order_by_style = explicit

[sqlfluff:rules:references:quoting]
prefer_quoted_keywords = True
1 change: 1 addition & 0 deletions transformers/synthetix/.sqlfluffignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target/
dbt_modules/
dbt_packages/
macros/
templates/
4 changes: 2 additions & 2 deletions transformers/synthetix/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ models:
+tags: "arbitrum_sepolia"
+schema: raw_arbitrum_sepolia
optimism:
+enabled: "{{ target.name == 'prod-op' }}"
+enabled: "{{ target.name == 'prod-op' or target.name == 'dev' }}"
mainnet:
+tags: "optimism_mainnet"
+schema: raw_optimism_mainnet
Expand All @@ -164,7 +164,7 @@ models:
+tags: "arbitrum_sepolia"
+schema: arbitrum_sepolia
optimism:
+enabled: "{{ target.name == 'prod-op' }}"
+enabled: "{{ target.name == 'prod-op' or target.name == 'dev' }}"
mainnet:
+tags: "optimism_mainnet"
+schema: optimism_mainnet
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,60 @@
WITH delegation_changes AS (
SELECT
with delegation_changes as (
select
block_timestamp,
account_id,
pool_id,
collateral_type,
{{ convert_wei('amount') }} - LAG({{ convert_wei('amount') }}, 1, 0) over (
PARTITION BY account_id,
pool_id,
collateral_type
ORDER BY
{{ convert_wei('amount') }}
- LAG({{ convert_wei('amount') }}, 1, 0) over (
partition by
account_id,
pool_id,
collateral_type
order by
block_timestamp
) AS change_in_amount
FROM
) as change_in_amount
from
{{ ref('core_delegation_updated_arbitrum_mainnet') }}
),
cumulative_delegation AS (
SELECT

cumulative_delegation as (
select
block_timestamp,
account_id,
pool_id,
collateral_type,
SUM(change_in_amount) over (
PARTITION BY pool_id,
account_id,
collateral_type
ORDER BY
partition by
pool_id,
account_id,
collateral_type
order by
block_timestamp
) AS cumulative_amount_delegated,
) as cumulative_amount_delegated,
ROW_NUMBER() over (
PARTITION BY pool_id,
account_id,
collateral_type
ORDER BY
block_timestamp DESC
) AS rn
FROM
partition by
pool_id,
account_id,
collateral_type
order by
block_timestamp desc
) as rn
from
delegation_changes
)
SELECT
block_timestamp AS ts,
CAST(
account_id AS text
) AS account_id,

select
block_timestamp as ts,
pool_id,
collateral_type,
cumulative_amount_delegated AS amount_delegated
FROM
cumulative_amount_delegated as amount_delegated,
CAST(
account_id as text
) as account_id
from
cumulative_delegation
WHERE
where
rn = 1
ORDER BY
order by
block_timestamp,
collateral_type
Loading
Loading