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

Allow for local compile of incremental models. #2403

Merged
merged 2 commits into from
Jan 9, 2023

Conversation

0xRobin
Copy link
Collaborator

@0xRobin 0xRobin commented Dec 26, 2022

This PR:

Enhances the default is_incremental logic to allow an override with a command line parameter.
The default value is set as False.
Usage:
dbt compile --vars '{force-incremental: True}'

The base logic was taken from here: is_incremental.sql

@0xRobin
Copy link
Collaborator Author

0xRobin commented Dec 26, 2022

  1. I'm not sure why but the pre-commit doesn't pick up the configs in macros/macros_schema.yml
  2. This will cause a full-refresh of all incremental models (which is not really necessary)
    We could manually run a general incremental update after merging (without full refresh) to prevent this.

@0xRobin 0xRobin added enhancement New feature or request ready-for-review this PR development is complete, please review labels Dec 26, 2022
@0xRobin
Copy link
Collaborator Author

0xRobin commented Jan 6, 2023

@dot2dotseurat @jeff-dude @soispoke
What do you think? :)

@dot2dotseurat
Copy link
Collaborator

Would we get the same thing from the proposed change in mentioned in this issue?

@0xRobin
Copy link
Collaborator Author

0xRobin commented Jan 7, 2023

@dot2dotseurat I don't think so, for me they don't really seem related.
This PR just allows us to locally get the compiled sql for an incremantal model (as if the is_incremental would return true)
It's really helpful when developing complex models and testing them out on Dune.

@dot2dotseurat dot2dotseurat merged commit 71590fa into duneanalytics:main Jan 9, 2023
@0xRobin
Copy link
Collaborator Author

0xRobin commented Jan 9, 2023

Thanks!
@cryptofreedman we should probably add a note of this in the docs somewhere.
I would add it next to "make sure to compile your models and test them out on Dune.com" but it seems we don't really suggest that anywhere currently. 🤔

Not sure where the best place would be

jeff-dude pushed a commit to MSilb7/spellbook that referenced this pull request Jan 9, 2023
* base is_incremental

* add force-incremental variable
jeff-dude added a commit that referenced this pull request Jan 10, 2023
* fix perp contract

* update token generations & move files

* mod aave sources

* update erc20 schema

* mod atoken sources

* fix indent

* aave sources alignment

* update aave schema again

* granary sources update

* more schema updates

* update ovm_optimism schema

* mod aave schema

* whoops - fix commas

* fix commas

* take - out of descriptions

* fixes

* expose OP erc20s as a separate detailed list

* map op back to erc20 tokens

* add standard to nft for op

* update dbt project

* add sided

* Update contracts_optimism_contract_creator_address_list.sql

* small

* typo

* Update tokens_optimism_schema.yml

* adds

* add dependency on snapshot

* Fix dbt_project.yml

* Update tokens_optimism_nft.sql

* remove generated tokens for now

* initialize without circular dependencies

* update prices

* update btc.b

* forget snapshot

* remove deps

* aave chain insert

* fix aave for loop

* fix atokens select

* simplify

* alias

* fix gran

* fix gran

note - granary initialized events are missing

* comment out descriptor

* erc20 schema

* fix

* Update tokens_optimism_erc20.sql

* price dupe

* update lists

* nft list

* fix unique nft

* add attestation override

* add mm swaps

* Update tokens_optimism_nft.sql

* add gysr

* add nft

* add erc20

* quix <> rh contract

* stick

* add type on atokens

* add woofi

* adds

* Reformat aave_v3_tokens for compatibility

* Fix typo

* Add uniqueness test

* Remove schema in config block

* Reformat granary_tokens and compatibility for Trino

* add token to prices

* adds

* add creator and update nft name

* revert OaycNFT renaming

* Apply CAST() to number_of_items and amount_raw

* fix tofu_bnb schema

* Add CAST() to fields

* fix fee convention

* Remove hardcoded fields from nft_trades

* convert to hours (#2399)

* [Easy] [Label] Implement trader platforms label (#2394)

* Implemented trader platforms label

* Fixed errors in spell

* Added forgotten group by

* Fixed columns selection

* Added ordering and keeping of order for label

* Fixed error in brackets

* Added missing block_time column

* Added time to keep order

* [easy] new tokens (#2414)

* Adding Aave V3 assets to tokens_avalanche_c_erc20.sql and tokens_polygon_erc20.sql (#2410)

* add AAVE, EURS to arbitrum_erc20.sql

* adding remaining aave v3 assets to erc20

* [CoW Protocol] Add Referral Mapping (#2377)

* add referral table

* remove duplicate anchor

* remove unused subquery

* Add Pancakeswap NFT Events (#2255)

* add seed in yml file

* Add Pancakeswap NFT V1 to nft trades

* delete tofu

* Adjust

* update

* update LOGIC

* initial commit

* update

* Update models/pancakeswap/bnb/pancakeswap_bnb_nft_market_v1_event.sql

Co-authored-by: 0xRob <[email protected]>

* Update models/pancakeswap/bnb/pancakeswap_bnb_nft_market_v1_event.sql

Co-authored-by: 0xRob <[email protected]>

* add test

* add

* Update models/pancakeswap/bnb/pancakeswap_bnb_nft_market_v1_event.sql

Co-authored-by: 0xRob <[email protected]>

* delete liquidifty

* add test file

* .

* update

* fix unique ID

* update sample file

* change pancakeswap seed schema

* temporary comment trade section

* reinstate test and correct columns

* change sample file

* change seed file

* add pancakeswap to nft trades

* add royalty info

* fix currency_symbol

* guard fee logic

* cast null as string

* remove double column

Co-authored-by: 0xRob <[email protected]>
Co-authored-by: 0xRob <[email protected]>

* Migrate Balancer `vebal_slopes` abstraction (#2179)

* Add balancer_vebal_slopes to schema yml file

* Add veBAL related sources to sources yml file

* Add balancer_vebal_slopes spell

* Reorder sources

* Change casting syntax

* Rename datetime field from schema .yml file

* Add incremental logic to vebal_slopes spell

* Update models/balancer/ethereum/balancer_vebal_slopes.sql

Co-authored-by: Huang Geyang <[email protected]>

* Update models/balancer/ethereum/balancer_vebal_slopes.sql

Co-authored-by: Huang Geyang <[email protected]>

* Update models/balancer/ethereum/balancer_ethereum_schema.yml

Co-authored-by: Huang Geyang <[email protected]>

* Update models/balancer/ethereum/balancer_vebal_slopes.sql

Co-authored-by: Huang Geyang <[email protected]>

* Replace block_time unique key for block_number

* Update models/balancer/ethereum/balancer_ethereum_schema.yml

Co-authored-by: Huang Geyang <[email protected]>

* Update models/balancer/ethereum/balancer_vebal_slopes.sql

Co-authored-by: Huang Geyang <[email protected]>

* Replace block_date for block_number in uniqueness test

* Rewrite group by in full column names

* Fix unmatched columns in schema.yml

* add descriptions to vebal_slopes columns

Co-authored-by: Huang Geyang <[email protected]>
Co-authored-by: Fábio Mendes <[email protected]>

* Update cow_protocol_ethereum_referrals.sql (#2423)

* Fix Source Chain ID/Name Hop Optimism (#2313)

* Update hop_protocol_flows.sql

* Revert "Update hop_protocol_flows.sql"

This reverts commit be30148.

* Update hop_protocol_optimism_flows.sql

* Add BSC Dodo trades to dex.trades (#2157)

* dodo-bnb-trades-real

* add seed tests

* seed value typo

* remove depracated test

* Modify dodo_bnb to aligh with dodo_eth in project.yml

* combine cross-chain bnb & ethereum trades

* correct ethereum dodo trades

* downgrade 'dbt_utils'

* Change back dbt_utils version to 0.9.2

* final tweaks

* force failure

* Remove extra line

* correct seed file

* restore deleted prices

* minor formatting

* cleanup dbt_project with latest standard

* add freshness check

Co-authored-by: Huang Geyang <[email protected]>
Co-authored-by: jeff-dude <[email protected]>

* script to find sources missing checks (#2401)

* script to find sources missing checks + new freshness checks

* T-22136: Missing ERC20 tokens (#2425)

* add A LOT of missing tokens

* sort + indentation

* escape backtick

* add missing comma

* remove last comma

* remove duplicate

* add trim to symbol

* remove trim, see if test pass

* fixed trim

Co-authored-by: jeff-dude <[email protected]>

* Update pull_request_template.md (#2429)

* Update README.md (#2411)

* T-23065 - optimism transfers: update value filter for string datatype (#2426)

* update value filter for string datatype

* directory cleanup

* Seaport ethereum patch (#2419)

* unifying seaport source

* keep unique_trade_id for opensea.trades for nft.trades compatability

* merge schema file

* cast amount to decimal(38,0)

* add test seeds

* update schema.yml

* Fix: minor typos (#2424)

* Fix: minor typos

Fix: minor typos

* Fix: minor typo

Fix: minor typo

* Fix: minor typo

Fix: minor typo

* Fix: minor typo

Fix: minor typo

* [Quick] Updates to metadata files (#2421)

* add new metadata

* fix duplicate error

Co-authored-by: cat <[email protected]>

* Added alphasharks.io as an aggregator (#2417)

* Fix aave liquidation call (#2432)

* FIX: cast to varchar in opensea_v3 trades (#2433)

* cast to varchar in concat in view

* define varchar length'

* use batch api calls for price checker (#2431)

* use batch api calls for price checker

* Update dodo_ethereum_trades & add dodo_bnb_trades & split them to aggregator and pools (#2169)

* update dodo_ethereum_trades && add dodo_bnb_trades

* split dodo_trades to pools & aggregator on Ethereum and BNBChain

* label different dodoV2 pools

* fix schema & sql

* add dodo_proxies on Ethereum

* Modify dodo_bnb_trades to incremental view

* Apply check_dex_seed and modify dodo_eth_trades to incremental view

* Add DODO bnb trade seeds

* Apply check_dex_seed to DODO bnb trades model

* update dex_trade_seeds

* fix

* Add DODO bnb in project.yml

* remove gitkeep in dodo

* Update models/dodo/bnb/dodo_pools_bnb_trades.sql

* Update check_dex_seed in dodo_ethereum_schema.yml

* fix dodo_ethereum_schema

* Remove schema in the config blocks

* Add dodo_trades files by scoffie

* add dppOracle & dppAdvanced to dodo_bnb

* fix

* update dbt_project on dodo

* fix dodo_bnb_sources.yml

* move cast to base model

* update dex.trades seeds on DODO_BNBChain

* final formatting & cleanup expose spell macro

Co-authored-by: Huang Geyang <[email protected]>
Co-authored-by: jeff-dude <[email protected]>

* [CoW] Fix Fee USD Calculation (#2422)

* use most natural form of fee computation when possible

* add comment about imprecision

* Fix failing tests (#2396)

* trigger test

* enable test in CI

* defer in test

* fix aragon

* fix native token test

* fix native mints unique id

* fix nft trader labels

* union all in nft labels

* union all for performance

* trigger wash_trades full refresh

* fix cow protocol distinct labels

* revert null wallet_address fix

Co-authored-by: soispoke <[email protected]>

* Add ETH Transfers to L1 (#2440)

* add eth transfers and small type fixes in op eth transfers

* comment update

* update schema

* update transfer id

* add tx to and from

* add tx_to and tx_from

* nit remove spaces

Co-authored-by: soispoke <[email protected]>

* Token checker tweaks (#2437)

* allow for case insensitive token symbol matching

* adapt token checker error/warns

* check for warning in test instead of error

* Allow for local compile of incremental models.  (#2403)

* base is_incremental

* add force-incremental variable

* clean up dbt_project values

* add version schema name

* rename ovm directory

* naming standards

* keep optimism erc20 view name

Co-authored-by: Huang Geyang <[email protected]>
Co-authored-by: 0xRob <[email protected]>
Co-authored-by: Belén Pruvost <[email protected]>
Co-authored-by: Meghan Heintz <[email protected]>
Co-authored-by: Gent Rexha <[email protected]>
Co-authored-by: josojo <[email protected]>
Co-authored-by: mc <[email protected]>
Co-authored-by: Benjamin Smith <[email protected]>
Co-authored-by: Harry <[email protected]>
Co-authored-by: 0xRob <[email protected]>
Co-authored-by: Victor Stefenon <[email protected]>
Co-authored-by: Fábio Mendes <[email protected]>
Co-authored-by: soispoke <[email protected]>
Co-authored-by: Levis Kithinji <[email protected]>
Co-authored-by: jeff-dude <[email protected]>
Co-authored-by: jeff-dude <[email protected]>
Co-authored-by: sohwak <[email protected]>
Co-authored-by: omahs <[email protected]>
Co-authored-by: catherine-2 <[email protected]>
Co-authored-by: cat <[email protected]>
Co-authored-by: Garv Maggu <[email protected]>
Co-authored-by: Dias <[email protected]>
Co-authored-by: owen05 <[email protected]>
@cryptofreedman
Copy link
Contributor

@0xRobin Noted, will do, ty!

@aranke
Copy link

aranke commented Feb 21, 2023

Hi @0xRobin,

I'm Kshitij from the dbt-core team and I'm a fan of Dune.
I'm currently working on interactive compile (dbt-labs/dbt-core#6358) which will display the compiled SQL for a single model in the terminal.
Let me know if this will solve your use case, thanks!

@0xRobin
Copy link
Collaborator Author

0xRobin commented Feb 21, 2023

Let me know if this will solve your use case, thanks!

@aranke thanks for reaching out, the proposed features certainly look useful!
But I don't think the current proposed setup would be able to replace our workaround here.
We're looking for the compiled SQL of an incremental model (as if is_incremental() would return true)

@0xRobin
Copy link
Collaborator Author

0xRobin commented Feb 21, 2023

@dot2dotseurat the --no-allow-introspection option that would be introduced could be a workaround for this other issue we're having with long compile times?

@dot2dotseurat
Copy link
Collaborator

@0xRobin I think it could but I'd want to do a little due diligence first on if this affects the manifest file or not. Specifically, I'd want us to double check how this affects finding state:modified models.

@0xRobin 0xRobin deleted the compile-incremental branch July 4, 2023 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready-for-review this PR development is complete, please review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants