* Bumping version to 1.2.4 and generate CHANGELOG
* Bumping version to 1.2.4 and generate CHANGELOG (#6521)
Co-authored-by: Github Build Bot <buildbot@fishtownanalytics.com>
* Update date
* Update date
Co-authored-by: Github Build Bot <buildbot@fishtownanalytics.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: leahwicz <60146280+leahwicz@users.noreply.github.com>
* Bumping version to 1.2.2rc1 and generate CHANGELOG
* Bumping version to 1.2.2 and generate CHANGELOG (#5997)
Co-authored-by: Github Build Bot <buildbot@fishtownanalytics.com>
Co-authored-by: Github Build Bot <buildbot@fishtownanalytics.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Preliminary changes to keep compile from connecting to the warehouse for runtime calls
* Adds option to lib to skip connecting to warehouse for compile; adds prelim tests
* Removes unused imports
* Simplifies test and renames to SqlCompileRunnerNoIntrospection
* Updates name in tests
* Spacing
* Updates test to check for adapter connection call instead of compile and execute
* Removes commented line
* Fixes test names
* Updates plugin to postgres type as snowflake isn't available
* Fixes docstring
* Fixes formatting
* Moves conditional logic out of class
* Fixes formatting
* Removes commented line
* Moves import
* Unmoves import
* Updates changelog
* Adds further info to method docstring
(cherry picked from commit f1326f526c)
Co-authored-by: Rachel <41338402+racheldaniel@users.noreply.github.com>
Add reusable function for retrying adapter connections. Utilize said function to add retries for Postgres (and Redshift).
Co-authored-by: Tomás Farías Santana <tomas@tomasfarias.dev>
* init push or ct-660 work
* changes to default versions of get_show_grant_sql and get_grant_sql
* completing init default versions of all macros being called for look over and collaboration
* minor update to should_revoke
* post pairing push up (does have log statements to make sure we remove)
* minor spacing changes
* minor changes, and removal of logs so people can have clean grab of code
* minor changes to how get_revoke_sql works
* init attempt at applying apply_grants to all materialzations
* name change from recipents -> grantee
* minor changes
* working on making a context to handle the diff gathering between grant_config and curreent_grants to see what needs to be revoked, I know if we assign a role, and a model becomes dependent on it we can't drop the role now still not seeing the diff appear in log
* removing logs from most materializations to better track diff of grants generation logs
* starting to build out postgres get_show_grant_sql getting empty query errors hopefully will clear up as we add the other postgres versions of macros and isn't a psycopg2 issue as indicated by searching
* 6/27 eod update looking into diff_grants variable not getting passed into get_revoke_sql
* changes to loop cases
* changes after pairing meeting
* adding apply_grants to create_or_replace_view.sql
* models are building but testing out small issues around revoke statement never building
* postgrest must fixes from jeremy's feedback
* postgres minor change to standarize_grants_dict
* updating after pairing with dough and jeremey incorporating the new version of should revoke logic.
* adding ref of diff_of_two_dicts to base keys ref
* change of method type for standardize_grants_dict
* minor update trying to fix unit test
* changes based on morning feedback
* change log message in default_apply_grants macro
* CT-808 grant adapter tests (#5447)
* Create initial test for grants
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* rename grant[privilege] -> grant_config[privilege]
* postgres macro rename to copy_grants
* CT-808 more grant adapter tests (#5452)
* Add tests for invalid user and invalid privilege
* Add more grant tests
* Macro touch ups
* Many more tests
* Allow easily replacing privilege names
* Keep adding tests
* Refactor macros to return lists, fix test
* Code checks
* Keep tweaking tests
* Revert cool grantees join bc Snowflake isnt happy
* Use Postgres/BQ as standard for standardize_grants_dict
* Code checks
* add missing replace
* small replace tweak, add additional dict diffs
* All tests passing on BQ
* Add type cast to test_snapshot_grants
* Refactor for DRYer apply_grants macros
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
Co-authored-by: Emily Rockman <emily.rockman@dbtlabs.com>
* update to main, create changelog, whitespace fixes
Co-authored-by: Gerda Shank <gerda@dbtlabs.com>
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
Co-authored-by: Emily Rockman <emily.rockman@dbtlabs.com>
* wip
* More support for ratio metrics
* Formatting and linting
* Fix unit tests
* Support disabling metrics
* mypy
* address all TODOs
* make pypy happy
* wip
* checkpoint
* refactor, remove ratio_terms
* flake8 and unit tests
* remove debugger
* quickfix for filters
* Experiment with functional testing for 'expression' metrics
* reformatting slightly
* make file and mypy fix
* remove config from metrics - wip
* add metrics back to context
* adding test changes
* fixing test metrics
* revert name audit
* pre-commit fixes
* add changelog
* Bumping manifest version to v6 (#5430)
* Bumping manifest version to v6
* Adding manifest file for tests
* Reverting unneeded changes
* Updating v6
* Updating test to add metrics field
* Adding changelog
* add v5 to backwards compatibility
* Clean up test_previous_version_state, update for v6 (#5440)
* Update test_previous_version_state for v6. Cleanup
* Regenerate, rm breakpoint
* Code checks
* Add assertion that will fail when we bump manifest version
* update tests to automatically tests all previous versions
Co-authored-by: Emily Rockman <emily.rockman@dbtlabs.com>
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
Co-authored-by: Callum McCann <cmccann51@gmail.com>
Co-authored-by: Emily Rockman <emily.rockman@dbtlabs.com>
Co-authored-by: leahwicz <60146280+leahwicz@users.noreply.github.com>
* Improve pluralizations for Documentation and SqlOperation NodeTypes
Previously these were `docss` and `sqlss` which leaves something to be
desired.
* Add changie changelog entry for pluralization change
* Slighly simplify node type pluralization tests
* Update node type names for sql and docs so they match pluralizations
* deleting scaffold and .py file from scripts section of core as they are either deprecated or will live outside of core
* adding changelog
* removing files that shouldn't be there
* update changelog to have link to new scaffold
* readding the original script file but changing its output ot be a print statement and leave comment that also points to the new scaffold
* sentence change
* Initialize lift + shift, dateadd + datediff
* Placeholder changelog for now
* Lift and shift cross-database macros, fixtures, and tests from dbt-utils
* Switch namespace from `dbt_utils` to `dbt`
* Remove unreferenced variable
* Remove conflicting definition of current_timestamp()
* Trim leading and trailing whitespace
* Apply Black formatting
* Remove unused import
* Remove references to other profiles
* Update .changes/unreleased/Features-20220518-114604.yaml
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* Kick out the `type_*` tests
* Kick out the `type_*` macros
* Kick out the `current_timestamp` tests
* Kick out the `current_timestamp` macros
* Kick out the `current_timestamp` macros
* Kick out the `type_*` macros
* Use built-in adapter functionality for converting string datatypes
* Move comment above macro for postgres__any_value
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* Adding scheduled CI testing Action
* Fixing malformed message
* Fixing messaging quotes
* Update to not fail fast
* Reordered branches
* Updating job name
* Removed PR trigger used for testing
* Fixing Windows color regression
* Cleaning up logic
* Consolidating logic to the logger
* Cleaning up vars
* Updating comment
* Removing unused import
* Fixing whitespace
* Adding changelog
* Handle 'grants' in NodeConfig, with correct merge behavior
* Fix a bunch of tests
* Add changie
* Actually add the test
* Change to default replace of grants with '+' extending them
* Additional tests, fix config_call_dict handling
* Tweak _add_config_call to remove unnecessary isinstance checks
* Setting up an env var to use to override the tox python variable used for local dev
* Switch over to py-based tox envs instead of the py38 ones to be friendly to dbt-core devs who don't work at dbt Labs
* changie
* Truncate relation names when appending a suffix that will result in len > 63 characters using make_temp_relation and make_backup_relation macros
* Remove timestamp from suffix appended to backup relation
* Add changelog entry
* Implememt make_relation_with_suffix macro
* Add make_intermediate_relation macro that controls _tmp relation creation in table and view materializations to delienate from database- and schema-less behavior of relation returned from make_temp_relation
* Create backup_relation at top of materialization to use for identifier
* cleanup
* Add dstring arg to make_relation_with_suffix macro
* Only reference dstring in conditional of make_relation_with_suffix macro
* Create both a temp and intermediate relation, update preexisting_temp_relation to preexisting_intermediate_relation
* Migrate test updates to new test location
* Remove restored tmp.csv
* Revert "Remove restored tmp.csv"
This reverts commit 900c9dbcad9a1e6a5a6737c84004504bfdd9926f.
* Actually remove restored tmp.csv
* Creating ADR for versioning and branching strategy
* Fixing image link
* Grammar clean-up
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Grammar clean-up
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Update docs/arch/adr-003-versioning-branching-strategy.md
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Update docs/arch/adr-003-versioning-branching-strategy.md
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Update docs/arch/adr-003-versioning-branching-strategy.md
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Update docs/arch/adr-003-versioning-branching-strategy.md
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Update docs/arch/adr-003-versioning-branching-strategy.md
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Update docs/arch/adr-003-versioning-branching-strategy.md
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Update docs/arch/adr-003-versioning-branching-strategy.md
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Update docs/arch/adr-003-versioning-branching-strategy.md
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Updating Outside Scope section
* Changing from using type to stage
* Adding section on getting changes into certain releases
* Changed stages to phases
* Some wording updates
* New section for branching pros and cons
* Clarifying version bump statement
* A few minor comment fix ups
* Adding requirement to define released
* Updating to completed!
Co-authored-by: Stu Kilgore <stuart.kilgore@gmail.com>
* Fix macro modified from previous state with pkg
When iterating through nodes to check if any of its macro dependencies
have been modified, the state selector will first check all upstream
macro dependencies before returning a judgement.
* Add a new selector method for files and add it to the default method selection criteria if the given selector has a . in it but no path separators
* Add a file: selector method to the default selector methods because it will make Pedram happy
* changie stuff
* fix: Avoid access to profile when calling str(UnsetProfileConfig)
dbt.config.UnsetProfileConfig inherits __str__ from
dbt.config.Project. Moreover, UnsetProfileConfig also raises an
exception when attempting to access unset profile attributes. As
Project.__str__ ultimately calls to_project_config and accesses said
profile attributes, we override to_project_config in
UnsetProfileConfig to avoid accessing the attributes that raise an
exception.
This allows calling str(UnsetProfileConfig) and
repr(UnsetProfileConfig).
Basic unit testing is also included in commit.
* fix: Skip repr for profile fields in UnsetProfileConfig
* chore(changie): Add changie file
* propseal for modification to drop_test_schema
* changelog
* remove hard coded run_dbt version and put back previous version of drop_test_schema, add commit to drop_schema
* When parsing 'all_sources' should be a list of unique dirs
* Changie
* Fix some unit tests of all_source_paths
* Convert 039_config_tests
* Remove old 039_config_tests
* Add test for duplicate directories in 'all_source_files'
* Convert existing metrics test
* add non-failing test for names with spaces
* Raise ParsingException if metrics name contains spaces
* Remove old metrics tests
* Fold so-called 'data' test into new framework with new vocabulary to match.
* Add missing files including changelog.
* Remove unneeded Changelog per team policy on test conversions.
* Refactor test code to better use our pytest framework. Strengthen assertions.
Co-authored-by: Mila Page <versusfacit@users.noreply.github.com>
* First test completed.
* Convert and update more test cases.
* Complete test migration and remove old files.
Co-authored-by: Mila Page <versusfacit@users.noreply.github.com>
* Use yaml renderer (with target context) for rendering selectors
* Changie
* Convert cli_vars tests
* Add test for var in profiles
* Add test for cli vars in packages
* Add test for vars in selectors
* Restore ability to configure and utilize `updated_at` for snapshots using the check_cols strategy
* Changelog entry
* Optional comparison of column names starting with `dbt_`
* Functional test for check cols snapshots using `updated_at`
* Comments to explain the test implementation
* Updating backport action to latest
* Updating to PR trigger with permissions instead
This is a better model for closing down all permissions and just granting what we actually want
* Updating IF when merged and backport label exists
* Changing to only trigger on label being added
* (finally) idiomatically rewrite a class of tests into the new framework.
* Get simple seed mostly working with design tweaks needed.
* Revamp tests to use more of the framework. Fix TODOs
* Complete migration of 005 and remove old files.
* Fix BOM test for Windows and add changelog entry
* Finalize tests in the adapter zone per conversation with Chenyu.
Co-authored-by: Mila Page <versusfacit@users.noreply.github.com>
I haven't added a message for stale PRs because they're likely to only impact the opening user (who I assume can reopen their own PR) and they're less of a problem. Happy to add that in as well, as well as to take feedback on the specific phrasing here.
* Flexibilize MarkupSafe pinned version
The current `MarkupSafe` pinned version has been added in #4746 as a
temporary fix for #4745.
However, the current restrictive approach isn't compatible with other
libraries that could require an even older version of `MarkupSafe`, like
Airflow `2.2.2` [0], which requires `markupsafe>=1.1.1, <2.0`.
To avoid that issue, we can allow a greater range of supported
`MarkupSafe` versions. Considering the direct dependency `dbt-core` has
is `Jinja2==2.11.3`, we can use its pinning as the lower bound, which is
`MarkupSafe>=0.23` [1].
This fix should be also backported this to `1.0.latest` for inclusion in
the next v1.0 patch.
[0] https://github.com/adamantike/airflow/blob/2.2.2/setup.cfg#L125
[1] https://github.com/pallets/jinja/blob/2.11.3/setup.py#L53
* Add selected_resources in the Jinja context
* Add tests for the Jinja variable selected_resources
* Add Changie entry for the addition of selected_resources
* Move variable to the ProviderContext
* Move selected_resources from ModelContext to ProviderContext
* Update unit tests for context to cater for the new selected_resources variable
* Move tests to a Class where tests are run after a dbt build
* cache schema for selected models
* Create Features-20220316-003847.yaml
* rename flag, update postgres adapter
rename flag to cache_selected_only, update postgres adapter: function _relations_cache_for_schemas
* Update Features-20220316-003847.yaml
* added test for cache_selected_only flag
* formatted as per pre-commit
* Add breaking change note for adapter plugin maintainers
* Fix whitespace
* Add a test
Co-authored-by: karunpoudel-chr <poudel.karun@gmail.com>
Co-authored-by: karunpoudel-chr <62040859+karunpoudel@users.noreply.github.com>
* initial pass at source config test w/o overrides
* Update tests/functional/sources/test_source_configs.py
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* Update tests/functional/sources/test_source_configs.py
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* tweaks from feedback
* clean up some test logic - add override tests
* add new fields to source config class
* fix odd formatting
* got a test working
* removed unused tests
* removed extra fields from SourceConfig class
* fixed next failing unit test
* adding back missing import
* first pass at adding source table configs
* updated remaining tests to pass
* remove source override tests
* add comment for config merging
* changelog
* remove old comments
* hacky fix for permission test
* remove unhelpful test
* adding back test file that was accidentally deleted
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
Co-authored-by: Nathaniel May <nathaniel.may@fishtownanalytics.com>
Co-authored-by: Chenyu Li <chenyu.li@dbtlabs.com>
* first draft
* working selector code
* remove debug print logs
* copy test template
* add todo
* smarter depends on graph searching notes
* add excluded source children nodes
* remove prints and clean up logger
* opinionated fresh node selection
* better if handling
* include logs with meaningul info
* add concurrent selectors note
* cleaner logging
* Revert "Merge branch 'main' of https://github.com/dbt-labs/dbt into feature/smart-source-freshness-runs"
This reverts commit 7fee4d44bf, reversing
changes made to 17c47ff42d.
* tidy up logs
* remove comments
* handle criterion that does not match nodes
* use a blank set instead
* Revert "Revert "Merge branch 'main' of https://github.com/dbt-labs/dbt into feature/smart-source-freshness-runs""
This reverts commit 71125167a1.
* make compatible with rc and new logger
* new log format
* new selector flag name
* clarify that status needs to be correct
* compare current and previous state
* correct import
* add current state
* remove print
* add todo
* fix error conditions
* clearer refresh language
* don't run wasteful logs
* remove for now
* cleaner syntax
* turn generator into set
* remove print
* add fresh selector
* data bookmarks matter only
* remove exclusion logic for status
* keep it DRY
* remove unused import
* dynamic project root
* dynamic cwd
* add TODO
* simple profiles_dir import
* add default target path
* headless path utils
* draft work
* add previous sources artifact read
* make PreviousState aware of t-2 sources
* make SourceFreshSelectorMethod aware of t-2 sources
* add archive_path() for t-2 sources to freshness.py
* clean up merged branches
* add to changelog
* rename file
* remove files
* remove archive path logic
* add in currentstate and previousstate defaults
* working version of source fresher
* syntax source_fresher: works
* fix quoting
* working version of target_path default
* None default to sources_current
* updated source selection semantics
* remove todo
* move to test_sources folder
* copy over baseline source freshness tests
* clean up
* remove test file
* update state with version checks
* fix flake tests
* add changelog
* fix name
* add base test template
* delegate tests
* add basic test to ensure nothing runs
* add another basic test
* fix test with copy state
* run error test
* run warn test
* run pass test
* error handling for runtime error in source freshness
* error handling for runtime error in source freshness
* add back fresher selector condition
* top level selector condition
* add runtime error test
* testing source fresher test selection methods
* fix formatting issues
* fix broken tests
* remove old comments
* fix regressions in other tests
* add Anais test cases
* result selector test case
Co-authored-by: Matt Winkler <matt.winkler@fishtownanalytics.com>
* init push up of converted unique_key tests
* testing cause of failure
* adding changelog entry
* moving non basic test up one directory to be more broadly part of adapter zone
* minor changes to the bad_unique_key tests
* removed unused fixture
* moving tests to base class and inheriting in a simple class
* taking in chenyu's changes to fixtures
* remove older test_unique_key tests
* removed commented out code
* uncommenting seed_count
* v2 based on feedback for base version of testing, plus small removal of leftover breakpoint
* create incremental test directory in adapter zone
* commenting out TableComparision and trying to implement check_relations_equal instead
* remove unused commented out code
* changing cast for date to fix test to work on bigquery
* start of a README for the include directory
* minor updates
* minor updates after comments from gerda and emily
* trailing space issue?
* black formatting
* minor word change
* typo update
* minor fixes and changelog creation
* remove changelog
* catch None and malformed json reponses
* add json.dumps for format
* format
* Cache registry request results. Avoid one request per version
* updated to be direct in type checking
* add changelog entry
* add back logic for none check
* PR feedback: memoize > global
* add checks for expected types and keys
* consolidated cache and retry logic
* minor cleanup for clarity/consistency
* add pr review suggestions
* update unit test
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* convert 059 to new test framework
* remove replaced tests
* WIP, has pre-commit errors
* WIP, has pre-commit errors
* one failing test, most issued resolved
* fixed final test and cleaned up fixtures
* remove converted tests
* updated test to work on windows
* remove config version
* Reorder kinds in changie
* Reorder change categories for v1.1.0b1
* Update language for breaking change
* Contributors deserve an h3
* Make pre-commit happy? Update language
* Rm trailing whitespace
* pre-commit additions
* added changie changelog entry
* moving integration test over
* Pair programming
* removing ref to mapping as seems to be unnecessary check, unique_key tests pass locally for postgres
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* convert changelog to changie yaml files
* update contributor format and README instructions
* update action to rerun when labeled/unlabled
* remove synchronize from action
* remove md file replaced by the yaml
* add synchronize and comment of what's happening
* tweak formatting
* FEAT: new columns in snapshots for adapters w/o bools
* trigger gha workflow
* using changie to make changelog
* updating to be on par with main
Co-authored-by: swanderz <swanson.anders@gmail.com>
* Change property file version exception to reflect current name and offer clearer guidance in comments.
* Add example in case of noninteger version tag just to drive the point home to readers.
* fix broken links, update GHA to not repost comment
* tweak GHA
* convert GHA used
* consolidate GHA
* fix PR numbers and pull comment as var
* fix name of workflow step
* changie merge to fix link at top of changelog
* add changelog yaml
* convert single test in 004
* WIP
* incremental conversion
* WIP test not running
* WIP
* convert test_missing_strategy, cross_schema_snapshot
* comment
* converting to class based test
* clean up
* WIP
* converted 2 more tests
* convert hard delete test
* fixing inconsistencies, adding comments
* more conversion
* implementing class scope changes
* clean up unsed code
* remove old test, get all new ones running
* fix typos
* append file names with snapshot to reduce collision
* moved all fixtures into test files
* stop using tests as fixtures
* Only select target column for not_null test
* If storing failures include all columns in the select, if not, only select the column being tested
It's desirable for this test to include the full row output when using --store-failures. If the query result stored in the database contained just the null values of the null column, it can't do much to contextualize why those rows are null.
* Update changelog
* chore: update changelog using changie
* Revert "Update changelog"
This reverts commit 281d805959.
* initial setup to use changie
* added `dbt-core` to version line
* fix formatting
* rename to be more accurate
* remove extra file
* add stug for contributing section
* updated docs for contributing and changelog
* first pass at changelog check
* Fix workflow name
* comment on handling failure
* add automatic contributors section via footer
* removed unused initialization
* add script to automate entire changelog creation and handle prereleases
* stub out README
* add changelog entry!
* no longer need to add contributors ourselves
* fixed formatted and excluded core team
* fix typo and collapse if statement
* updated to reflect automatic pre-release handling
Removed custom script in favor of built in pre-release functionality in new version of changie.
* update contributing doc
* pass at GHA
* fix path
* all changed files
* more GHA work
* continued GHA work
* try another approach
* testing
* adding comment via GHA
* added uses for GHA
* more debugging
* fixed formatting
* another comment attempt
* remove read permission
* add label check
* fix quotes
* checking label logic
* test forcing failure
* remove extra script tag
* removed logic for having changelog
* Revert "removed logic for having changelog"
This reverts commit 490bda8256.
* remove unused workflow section
* update header and readme
* update with current version of changelog
* add step failure for missing changelog file
* fix typos and formatting
* small tweaks per feedback
* Update so changelog end up onlywith current version, not past
* update changelog to recent contents
* added the rest of our releases to previous release list
* clarifying the readme
* updated to reflect current changelog state
* updated so only 1.1 changes are on main
* Fix macro modified from previous state
Previously, if the first node selected by state:modified had multiple
dependencies, the first of which had not been changed, the rest of the
macro dependencies of the node would not be checked for changes. This
commit fixes this behavior, so the remainder of the macro dependencies
of the node will be checked as well.
* Convert tests in dbt-adapter-tests to use new pytest framework
* Filter out ResourceWarning for log file
* Move run_sql to dbt.tests.util, fix check_cols definition
* Convert jaffle_shop fixture and test to use classes
* Tweak run_sql methods, rename some adapter file pieces, add comment
to dbt.tests.adapter.
* Add some more comments
* Create DictDefaultNone for to_target_dict in deps and clean commands
* Update test case to handle
* update CHANGELOG.md
* Switch to DictDefaultEmptyStr for to_target_dict
* Do not overwrite node.meta with empty patch.meta
* Restore config_call_dict in snapshot node transform
* Test for snapshot with schema file config
* Test for meta in both toplevel node and node config
* task init: support older click v7.0
`dbt init` uses click for interactively setting up a project. The
version constraints currently ask for click >= 8 but v7.0 has nearly the
same prompt/confirm/echo API. prompt added a feature that isn't used.
confirm has a behavior change if the default is None, but
confirm(..., default=None) is not used. Long story short, we can relax
the version constraint to allow installing with an older click library.
Ref: Issue #4566
* Update CHANGELOG.md
Co-authored-by: Chenyu Li <chenyulee777@gmail.com>
Co-authored-by: Chenyu Li <chenyulee777@gmail.com>
* adapter compability messaging added.
* edited plugin version compatibility message
* edited test version for plugin compability
* compare using only major and minor
* Add checking PYPI and update changelog
Co-authored-by: Chenyu Li <chenyulee777@gmail.com>
Co-authored-by: ChenyuLi <chenyu.li@dbtlabs.com>
* Add unique_key to NodeConfig
`unique_key` can be a string or a list.
* merge.sql update to work with unique_key as list
extend the functionality to support both single and multiple keys
Signed-off-by: triedandtested-dev (Bryan Dunkley) <bryan@triedandtested.dev>
* Updated test to include unique_key
Signed-off-by: triedandtested-dev (Bryan Dunkley) <bryan@triedandtested.dev>
* updated tests
Signed-off-by: triedandtested-dev (Bryan Dunkley) <bryan@triedandtested.dev>
* Fix unit and integration tests
* Update Changelog for 2479/4618
Co-authored-by: triedandtested-dev (Bryan Dunkley) <bryan@triedandtested.dev>
* new docker setup
* formatting
* Updated spark: support for extras
* Added third-party adapter support
* More selective lib installs for spark
* added docker to bumpversion
* Updated refs to be tag-based because bumpversion doesn't understand 'latest'
* Updated docs per PR feedback
* reducing RUNs and formatting/pip best practices changes
* Added multi-architecture support and small test script, updated docs
* typo
* Added a few more tests
* fixed tests output, clarified dbt-postgres special case-ness
* Fix merge conflicts
* formatting
* Updated spark: support for extras
* Added third-party adapter support
* More selective lib installs for spark
* added docker to bumpversion
* Updated refs to be tag-based because bumpversion doesn't understand 'latest'
* Updated docs per PR feedback
* reducing RUNs and formatting/pip best practices changes
* Added multi-architecture support and small test script, updated docs
* typo
* Added a few more tests
* fixed tests output, clarified dbt-postgres special case-ness
* changelog
* basic framework
* PR ready excepts docs
* PR feedback
* add retry logic, tests when extracting tarfile fails
* fixed bug with not catching empty responses
* specify compression type
* WIP test
* more testing work
* fixed up unit test
* add changelog
* Add more comments!
* clarify why we do the json() check for None
* Initial addition of CODEOWNERS file
* Proposed sub-team ownership (#4632)
* Updating for the events module to be both language and execution
* Adding more comment details
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* Validate project names in interactive dbt init
- workflow: ask the user to provide a valid project name until they do.
- new integration tests
- supported scenarios:
- dbt init
- dbt init -s
- dbt init [name]
- dbt init [name] -s
* Update Changelog.md
* Add full URLs to CHANGELOG.md
Co-authored-by: Chenyu Li <chenyulee777@gmail.com>
Co-authored-by: Chenyu Li <chenyulee777@gmail.com>
* scrub message of secrets
* update changelog
* use new scrubbing and scrub more places using git
* fixed small miss of string conv and missing raise
* fix bug with cloning error
* resolving message issues
* better, more specific scrubbing
* [#4464] Check specifically for generic node type for some partial parsing actions
* Add check for existence of macro file in saved_files
* Check for existence of patch file in saved_files
* updating contributing.md based on suggestions from updates to adapter contributing files.
* removed section refering to non-postgres databases for core contributing.md
* making suggested changes to contributing.md based on kyle's initial lookover
* Update CONTRIBUTING.md
Co-authored-by: Kyle Wigley <kyle@fishtownanalytics.com>
Co-authored-by: Kyle Wigley <kyle@fishtownanalytics.com>
* add node type codes to more events + more hook log
* minor fixes
* renames started/finished keys
* made process more clear
* fixed errors
* Put back report_node_data in fresshness.py
Co-authored-by: Gerda Shank <gerda@dbtlabs.com>
* Rm unused events, per #4104
* More structured ConcurrencyLine
* Replace \n prefixes with EmptyLine
* Reimplement ui.warning_tag to centralize logic
* Use warning_tag for deprecations too
* Rm more unused event types
* Exclude EmptyLine from json logs
* loglines are not always created by events (#4406)
Co-authored-by: Nathaniel May <nathaniel.may@fishtownanalytics.com>
* WIP
* fixed some merg issues
* WIP
* first pass with node_status logging
* add node details to one more
* another pass at node info
* fixed failures
* convert to classes
* more tweaks to basic implementation
* added in ststus, organized a bit
* saving broken state
* working state with lots of todos
* formatting
* add start/end tiemstamps
* adding node_status logging to more events
* adding node_status to more events
* Add RunningStatus and set in node
* Add NodeCompiling and NodeExecuting events, switch to _event_status dict
* add _event_status to SourceDefinition
* small tweaks to NodeInfo
* fixed misnamed attr
* small fix to validation
* rename logging timestamps to minimize name collision
* fixed flake failure
* move str formatting to events
* incorporate serialization changes
* add node_status to event_to_serializable_dict
* convert nodeInfo to dict with dataclass builtin
* Try to fix failing unit, flake8, mypy tests (#4362)
* fixed leftover merge conflict
Co-authored-by: Gerda Shank <gerda@dbtlabs.com>
* Log formatting from flags earlier
* WARN-level stdout for list task
* Readd tracking events to File
* PR feedback, annotate hacks
* Revert "PR feedback, annotate hacks"
This reverts commit 5508fa230b.
* This is maybe better
* Annotate main.py
* One more comment in base.py
* Update changelog
* pushing up to get eye on from Nate
* updating to compare
* latest push
* finished test for duplicate codes with a lot of help from Nate
* resolving suggestions
* removed duplicated code in types.py, made minor changes to test_events.py
* added missing func call
* simplified data construction
* fixed missed scrubbing of secrets
* switched to vars()
* scrub entire log line, update how attributes get pulled
* get ahead of serialization errors
* store if data is serialized and modify values instead of a copy of values
* fixed unused import from merge
* start adding version logging, noticed some wrong stuff
* fix bad pid and ts
* remove level format on json logs
Co-authored-by: Emily Rockman <emily.rockman@dbtlabs.com>
* Address 3997. Test selection flag can be in profile.yml.
* Per Jerco's 4104 PR unresolved comments, unify i.s. predicate and add env var.
* Couple of flake8 touchups.
* Classier error handling using enum semantics.
* Cherry-pick in part of Gerda's commit to hopefully avoid a future merge conflict.
* Add 3997 to changelog.
Co-authored-by: Mila Page <versusfacit@users.noreply.github.com>
* added struct logging to base
* fixed merge wierdness
* convert to use single type for integration tests
* converted to 3 reusable test types in sep module
* tweak message
* clean up and making test_types complete for future
* fix missed import
* add struct logging to compilation
* add struct logging to tracking
* add struct logging to utils
* add struct logging to exceptions
* fixed some misc errors
* updated to send raw ex, removed resulting circ dep
* add struct logging to docs serve
* remove merge fluff
* struct logging to seed command
* converting print to use structured logging
* more structured logging print conversion
* pulling apart formatting more
* added struct logging by disecting printer.py
* add struct logging to runnable
* add struct logging to task init
* fixed formatting
* more formatting and moving things around
* convert generic_test to structured logging
* convert macros to structured logging
* add struc logging to most of manifest.py
* add struct logging to models.py
* added struct logging to partial.py
* finished conversion of manifest
* fixing errors
* fixed 1 todo and added another
* fixed bugs from merge
* update config use structured logging
* WIP
* minor cleanup
* fixed merge error
* added in ShowException
* added todo to remove defaults after dropping 3.6
* removed todo that is obsolete
* first cut at supporting metrics definitions
* teach dbt about metrics
* wip
* support partial parsing for metrics
* working on tests
* Fix some tests
* Add partial parsing metrics test
* Fix some more tests
* Update CHANGELOG.md
* Fix partial parsing yaml file to correct model syntax
Co-authored-by: Drew Banin <drew@fishtownanalytics.com>
* [#3885] Partially parse when environment variables in schema files
change
* Add documentation for test kwargs
* Add test and fix for schema configs with env_var
* Fix issue #4178
Allow retries when the answer is None
* Include fix for #4178
Allow retries when the answer from dbt deps is None
* Add link to the PR
* Update exception and shorten line size
* Add test when dbt deps returns None
* Raise error on pip install dbt
* Fix relative path logic
* Do not build dist for dbt
* Fix long descriptions
* Trigger code checks
* Using root readme more trouble than good
* only fail on install, not build
* Edit dist script. Avoid README duplication
* jk, be less clever
* Ignore 'dbt' source distribution when testing
* Add changelog entry
Co-authored-by: Kyle Wigley <kyle@dbtlabs.com>
* Parser no longer takes greedy. Accepts indirect selection, a bool.
* Remove references to greedy and supporting functions.
* 1. Set testing flag default to True. 2. Improve arg parsing.
* Update tests and add new case for when flag unset.
* Update names and styling to fit test requirements. Add default value for option.
* Correct several failing tests now that default behavior was flipped.
* Tests expect eager on by default.
* All but selector test passing.
* Get integration tests working, add them, and mix in selector syntax.
* Clean code and correct test.
* Add changelog entry
Co-authored-by: Mila Page <versusfacit@users.noreply.github.com>
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* Use common columns for incremental schema changes
* on_schema_change:append_new_columns should gracefully handle column removal
* review changes
* Lean approach for `process_schema_changes` to simplify
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* Update profile_template.yml to use same syntax as target_options.yml
* Rename target_options to profile_template
* Update profile_template config spec
* Add project name to default search packages
We prefer macros in the project over the ones in the namespace (package)
* Add change to change log
* Use project_name instead of project
* Raise compilation error if no macros are found
* Update change log line
* Add test for package macro override
* Add JCZuurmond to contributor
* Fix typos
* Add test that should not over ride the package
* Add doc string to tests
* added support for dbs without boolean types
* catch errors a bit better
* moved changelog entry
* fixed tests and updated exception
* cleaned up bool check
* added positive test, removed self ref
* removed overlooked breakpoint
* first pass
* save progress - singualr tests broken
* fixed to work with both generic and singular tests
* fixed formatting
* added a comment
* change to use /generic subfolder
* fix formatting issues
* fixed bug on code consolidation
* fixed typo
* added test for generic tests
* added changelog entry
* added logic to treat generic tests like macro tests
* add generic test to macro_edges
* fixed generic tests to match unique_ids
* fixed test
* Fix setup_db.sh by waiting for pg_isready success return. Fixes#3876
* restored noaccess and dbtMixedCase creation and updated changelog and contributing md files
* restored root auth commands
* restored creation of dbt schema, aparently this is needed even if docker compose also creates it...
* pr comments: avoid infinite loop and quote variables
* Update changelog
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* Initial
* Further dev
* Make mypy happy
* Further dev
* Existing tests passing
* Functioning integration test
* Passing integration test
* Integration tests
* Add changelog entry
* Add integration test for init outside of project
* Fall back to target_options.yml when invalid profile_template.yml is provided
* Use built-in yaml with exception of in init
* Remove oyaml and fix tests
* Update dbt_project.yml in test comparison
* Create the profiles directory if it doesn't exist
* Use safe_load
* Update integration test
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* Add result: selection method
* make a copy for modified state test suite
* test case notes
* remove macro tests
* add a test setup command
* copy run results state
* passing test case, todos, split work
* clean up result:success test case
* start with build command and remove previous state where needed
* add error result selector tests for seed
* add another error seed test case
* remove todo
* passing build result:error tests
* single failure build test
* add passing test
* fix node assertions for tests
* fix tests
* draft fail+ tests
* add severity to test
* result:warn passing test
* result:warn+ passing tests
* add passing concurrent selector test
* add downstream flag
* add comment
* passing test
* fix test for dynamic node selection
* add build concurrent selector passing test
* add run test cases
* add integration tests for dbt test
* fix formatting
* rename test
* remove extra comments
* add extra newline
* add concurrent selector test / build cases
* clean up todos
* test all nodes
* DRY rebuild code
* test all nodes
* add TODO update assertion code
* cleaner assert code
* fix this test to have a fixed set
* more cleanup
* add changelog
* update concurrent selectors on dbt test
* remove todo
* Update changelog
* Apply suggestions from code review
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
* fix changelog
* fix Contributors headers
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
Co-authored-by: Matt Winkler <matt.winkler@fishtownanalytics.com>
* WIP to replace source_path with model_path
* updated some test to point to new testing branches
https://github.com/dbt-labs/dbt-integration-project needs updates to get all tests working
* deprecate souce_paths but not remove fully
* added deprecation test for path deprecation
* replace data-pathswith seed-paths: ['seeds']
ypdated tests to use default directory of 'seeds' instead of 'data'
* added test for exception when paths incorectly defined
source-paths and data-paths have been deprecated in favor of model-paths and seed-paths. You can still use the deprecated keys but you cannot define both the deprecated and new keys since we wouldn't know how to handle it.
* fixed test naming issue
* fix formatting issues, standardize names
* updated branches for dbt-integration-project
* updated changelog
* synced up rpc deletion messed up when merging
* changelog updates
* rm rpc specfic code, still more references to rpc to clean up (rpc_method, integration tests, etc.)
* rm move references to rpc
* rm tests against rpc server
* rm more rpc files
* more code!
* sorry!
* Change the data type of `sources` of `ParsedNodeDefaults`
* Add the statement about the change to `CHANGELOG.md`
* Add myself to the contributors
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
Update the default project paths to be `analysis-paths = ['analyses']` and `test-paths = ['tests]`. Also have starter project set `analysis-paths: ['analyses']` from now on. Fixed all associated tests.
* Change the default dbt packages installation directory to `dbt_packages` from `dbt_modules`. Also rename `module-path` to `packages-install-path` to allow default overrides of package install directory. Deprecation warning added for projects using the old `dbt_modules` name without specifying a `packages-install-path`.
* fixed deprecation test bug
* Fixed wording on deprecation warning.
* enacted deprecation for dispatch-packages, cleaned up deprecations tests for unused macros/models. still need to clean up unused code.
* more work to catch packages use
* fixed tests for removing packages on adapter.dispatch.
* cleaned out folder for 012_deprecation_tests to remove unused models/data/macros
* removed obsolete code due to patching for packages arg in adapter.dispatch
* updated exception name
* added deprecation change to changelog.
Add --greedy flag to subparser
Add greedy flag, override default behaviour when parsing union
Add greedy support to ls (I think?!)
That was suspiciously easy
Fix flake issues
Try adding tests with greedy support
Remove trailing whitespace
Fix return type for select_nodes
forgot to add greedy arg
Remove incorrectly expected test
Use named param for greedy
Pull alert_unused_nodes out into its own function
rename resources -> tests
Add expand_selection explanation of --greedy flag
Add greedy support to yaml selectors. Update warning, tests
Fix failing tests
Fix tests. Changelog
Fix flake8
Co-authored-by: Joel Labes c/o Jeremy Cohen <jeremy@dbtlabs.com>
* group by column_name in accepted_values
Group by index is not ANSI SQL and not supported in every database engine (e.g. MS SQL). Use group by column_name in shared code.
* update changelog
* Changed how tables and views are generated to be able to use different options
* 3682 added unit tests
* 3682 had conflict in changelog and became a bit messy
* 3682 Tested to add default kms to dataset and accidently pushed the changes
* Add warning about new package name
* Update CHANGELOG.md
* make linter happy
* Add warning about new package name
* Update CHANGELOG.md
* make linter happy
* move warnings to deprecations
* Update core/dbt/clients/registry.py
Co-authored-by: leahwicz <60146280+leahwicz@users.noreply.github.com>
* add comments for posterity
* Update core/dbt/deprecations.py
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* add deprecation test
Co-authored-by: leahwicz <60146280+leahwicz@users.noreply.github.com>
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* Parametrize key selectinf for list task
* Remove trailing whitespace
* Add output_keys to RPC List Parameters
* Move up changelog entry, add contributor note
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* Add colourful count of pass/fail tests in dbt debug
* Remove number of checks, move error messages into shared list
* Fix flake issues
* Update CHANGELOG.md
* configurable postgres connect timeout
* changelog for #3582
* test default and change connect_timeout
* Move up contributor note in changelog
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* add bq alias for target_project and target_dataset
* Update CHANGELOG.md
add #3694 to changelog
* Update CHANGELOG.md
Be more specific about the change to bigquery synonym for schema only.
* Set integration test bigquery configs to use alias
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* fewer adapters will need to re-implemnt basic_load_csv_rows
* hack version
* reordering per convention
* make redundant basic_load_csv_rows
* for next version
* Update core/dbt/include/global_project/macros/materializations/seed/seed.sql
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
* Move up changelog entry
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* start blueprinting changes
* extend registry handler for latest package version
* conditional logging for latest version
* remove todo
* add conditional logging
* Upgrades is clearer
* update if elif conditions and log msg
* remove TODO
* fix flake8 errors
* blueprint unit tests
* conditions specific to hub registry
* 1 passing test for get latest version
* DRY method calls
* move version latest to hub only
* add a new line
* remove other draft tests
* update changelog
* update log language for clarity
* pass flake8
* fix changelog
* Update test/unit/test_deps.py
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* update changelog
* remove hub language
* sort for latest version and include prereleases
* fix flake8
* resolves another issue
* fix prerelease string formatting
* fix broken test
* update logging to past tense
* built-in version sorting
* handle prereleases for latest version checks
* get version latest unit test based on prerelease
* update unit test for sorting functionality
* consistent test names
* fix flake8
* clean up contributors list
* simplify if else logic
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* Change BigQuery copy materialization
Change BigQuery copy materialization macros to copy data from several sources into single target
* Change BigQuery copy materialization
Change BigQuery connections.py to copy data from several sources into single target via copy materialization
* Change BigQuery copy materialization
Test to check default value of `copy_materialization` if it is absent in config
* Change BigQuery copy materialization
Update changelog
* Update changelog
* Var renaming + test addition
* Changelog updated
* Changelog updated
* Fix test for copy table
* Update test_bigquery_adapter.py
* Update test_bigquery_adapter.py
* Update impl.py
* Update connections.py
* Update test_bigquery_adapter.py
* Update test_bigquery_adapter.py
* Update connections.py
* Align calls from mock and from adapter
* Split long code ilnes
* Create additional.sql
* Update copy_as_several_tables.sql
* Update schema.yml
* Update copy.sql
* Update connections.py
* Update test_bigquery_copy_models.py
* Add contributor
* test
* test test
* try this again
* test actions in same repo
* nvm revert
* formatting
* fix sh script for building dists
* fix windows build
* add concurrency
* fix random 'Cannot track experimental parser info when active user is None' error
* fix build workflow
* test slim ci
* has changes
* set up postgres for other OS
* update descriptions
* turn off python3.9 unit tests
* add changelog
* clean up todo
* Update .github/workflows/main.yml
* create actions for common code
* temp commit to test
* cosmetic updates
* dev review feedback
* updates
* fix build checks
* rm auto formatting changes
* review feeback: update order of script for setting up postgres on macos runner
* review feedback: add reasoning for not using secrets in workflow
* review feedback: rm unnecessary changes
* more review feedback
* test pull_request_target action
* fix path to cli tool
* split up lint and unit workflows for clear resposibilites
* rm `branches-ignore` filter from pull request trigger
* testing push event
* test
* try this again
* test actions in same repo
* nvm revert
* formatting
* fix windows build
* add concurrency
* fix build workflow
* test slim ci
* has changes
* set up postgres for other OS
* update descriptions
* turn off python3.9 unit tests
* add changelog
* clean up todo
* Update .github/workflows/main.yml
* create actions for common code
* cosmetic updates
* dev review feedback
* updates
* fix build checks
* rm auto formatting changes
* review feedback: add reasoning for not using secrets in workflow
* review feedback: rm unnecessary changes
* more review feedback
* test pull_request_target action
* fix path to cli tool
* split up lint and unit workflows for clear resposibilites
* rm `branches-ignore` filter from pull request trigger
* test dynamic matrix generation
* update label logic
* finishing touches
* align naming
* pass opts to pytest
* slim down push matrix, there are a lot of jobs
* test bump num of proc
* update matrix for all event triggers
* handle case when no changes require integration tests
* dev review feedback
* clean up and add branch name for testing
* Add test results publishing as artifact (#3794)
* Test failures file
* Add testing branch
* Adding upload steps
* Adding date to name
* Adding to integration
* Always upload artifacts
* Adding adapter type
* Always publish unit test results
* Adding comments
* rm unecessary env var
* fix changelog
* update job name
* clean up python deps
Co-authored-by: leahwicz <60146280+leahwicz@users.noreply.github.com>
* add blueprints to resolve issue
* revert to previous version
* intentionally failing test
* add imports
* add validation in existing function
* add passing test for length validation
* add current sanitized label
* remove duplicate var
* Make logging output 2 lines
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* Raise RuntimeException to better handle error
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* update test
* fix flake8 errors
* update changelog
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* table and view materializations should rename from old_relation to manage changes from view to table and reverse
* edited changelog
* edited changelog
* Update CHANGELOG.md
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
* Rm Snowflake txnal logic. Explicit for DML
* Be less clever. Update create_or_replace_view()
* Seed DML as well
* Changelog entry
* Fix unit test
* One semicolon can change the world
* skip all tracking event testing
* Turn off tracking in tests that hits model parsing code path
fix other random test that fails because global tracking.current_user exists but is null
* pytest did not respect skip mark
* fix gh actions
* cli: add selection args for source freshness command
* rename command to `source freshness` and maintain alias to old command
* update and add tests for source freshness command and node selection
* update changelog, add comments
* fix formatting
* update changelog
* Fix docs generation for cross-db sources in REDSHIFT RA3 node (#3408)
* Fix docs generating for cross-db sources
* Code reorganization
* Code adjustments according to flake8
* Error message adjusted to be more precise
* CHANGELOG update
* add static analysis info to parsing data
* update changelog
* don't use `meta`! need better separation between dbt internal objects and external facing data. hacked an internal field on the manifest to save off this parsing info for the time being
* fix partial parsing case
Co-authored-by: kostek-pl <67253952+kostek-pl@users.noreply.github.com>
Allows users to optionally set values for sslcert, sslkey, and
sslrootcert in their Postgres profiles.
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* dispatch logic of new test materialization
allow custom adapters to override the core test select statement functionality
* rename macro
* raconte moi une histoire
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* Fix docs generating for cross-db sources
* Code reorganization
* Code adjustments according to flake8
* Error message adjusted to be more precise
* CHANGELOG update
* New test configs: where, limit, warn_if, error_if
* update test task and tests
* fix flake8
* Update core/dbt/parser/schemas.py
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* Update core/dbt/parser/schema_test_builders.py
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* respond to some feedback
* add failures field
* add failures to results
* more feedback
* add some test coverage
* dev review feedback
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* Add meta and tags to parsed and unparsed
* Fix tests
* Add meta and tags to unparsed schema
* Update Changelog
* Remove "optional" specifier and add default values
* Fix exposure schemas for PG Integration tests
used in parsing schema tests by looking at the arguments to
adapter.dispatch. Includes providing an alternative way of specifying
macro search order in project config.
Collaboratively developed with Jeremy Cohen.
Co-authored-by: Gerda Shank <gerda@fishtownanalytics.com>
* 🔨 Add ssh-client and update git version using debian backports in Docker image
* ✏️ Update CHANGELOG
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* (explicitly) find the executable before running run_cmd
#3035
* fix undefined var
* use Executable to say exe not found and use full pth to exe
* changelog for #3035
* Nest shutil.which for better error msg
Co-authored-by: Majid alDosari <majidaldosari-github@yahoo.com>
Co-authored-by: Kyle Wigley <kyle@fishtownanalytics.com>
* Add a better error for undefined macros
* Add check/error when installed packages < specified packages
* fix integration tests
* Fix issue with null packages
* Don't call _get_project_directories() twice
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
* Fix some integration and unit tests
* Make mypy happy
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
* Fix docs and rpc integration tests
* Fix (almost) all the rpc tests
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
* Check if column exists when altering column comments in snowflake
* Add new test class for persist docs models with missing columns
* Parallel run all integration tests after unit (#3328)
* don't clobber default args
* update changelog
* Update changelog for PR #3149
* Pull in upstream changes
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
Co-authored-by: Kyle Wigley <kyle@fishtownanalytics.com>
* Now generating a run_results.json even when no nodes are selected.
* Typo in changelog
* Modified changelog in accordance with @jtcohen6's suggestions. Also fixed @TeddyCr's entry.
* added logic to timeout request after 60 seconds + unit test
* fixed typo in comment
* Update test URL for azure CI failure
* Update changelog + change endpoint for timeout test + added retry logic to the timeout exception
* updated exception catching to a generic one + adjusted tests based on error catching + renamed test file accordingly
* updated comment in test_registry_get_request_exception.py to reflect new approach
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* Add test, expect fail
* Include parent adapters in dispatch
* Use adapter type, not credentials type
* Adjust adapter_macro deprecation test
* fix test/unit/test_context.py to use postgres profile
* Add changelog note
* Redshift default column encoding now AUTO
Co-authored-by: Gerda Shank <gerda@fishtownanalytics.com>
* Support dots in model names. They are useful as namespace separators
* Update CHANGELOG.md
* Update contributor list
* Extend integration test to support models whose name contains dots
* Cleanup fqn selection login
* Explain condition check
* Support dots in model names: integration tests
* Make linter happy: remove trailing whitespaces
* Support dots in model names: integration test for seeds
* revert 66c26facbd. Integration tests to support dots in model names implemented in 007_graph_selection_tests
* Test model with dots only in postgres. It's meant to work in combination with custom macros for other databases
* Support dot as namespace separators: integration test
* Support dots in test names: integration test
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* 🔨 Extend git package contract and signatures to pass `subdirectory`
* Add sparse checkout logic
* ✅ Add test
* 🧹 Lint
* ✏️ Update CHANGELOG
* 🐛 Make os.path.join safe
* Use a test-container with an updated `git` version
* 🔨 Fix integration tests
* 📖 Update CHANGELOG contributors to include this PR
* 🧪 Parameterize the test
* Use new test-container published by @kwigley (contains more recent version of git)
* Use repositories managed by fishtown
* 🧘♂️ Merge the CHANGELOG
* 🤦♂️ Remove repetition of my contribution on the CHANGELOG
Co-authored-by: Jeremy Cohen <jeremy@fishtownanalytics.com>
* Add TestCLIInvocationWithProfilesAndProjectDir
* Add context manager for changing working directory
* Add fixture for changing working directory to temporary directory
* Add missing import
* Move custom profile into function
* Add function to create profiles directory
* Remove path and union
* Make temporary_working_directory a context manager
* Fix some issues, wrong naming and invocation
* Update test with profiles and project dir
* Use a fixture for the sub command
* Run test for debug and run sub command
* Resolve inheritance
* Remove profiles from project dir
* Use pytest mark directly instead of use_profile
* Use parameterize on class
* Remove parameterize
* Create separate test for each subcommand
* Set profiles_dir to false
* Add run test
* Use abspath
* Add entry to change log
* Add suggested changes
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
* Remove test_postgres_run_with_profiles_separate_from_project_dir
* Add JCZuurmond to change log
* Add test_postgres_run_with_profiles_separate_from_project_dir
* Remove HEAD
* Fix wrong merge
* Add deps before test
* Add run to test which runs test command
* Sort tests
* Force rerun
* Force rerun
* Force rerun
Co-authored-by: Jeremy Cohen <jtcohen6@gmail.com>
mapped_fields in the classes for 'from_dict', removing deepcopy
on fqn_search, separating validation from 'from_dict',
and special handling for dbt internal not_null and unique tests.
Use TestMacroNamespace instead of original in order to limit
the number of macros in the context. Integrate mashumaro into
dbt to improve performance of 'from_dict' and 'to_dict'
mapped_fields in the classes for 'from_dict', removing deepcopy
on fqn_search, separating validation from 'from_dict',
and special handling for dbt internal not_null and unique tests.
Use TestMacroNamespace instead of original in order to limit
the number of macros in the context. Integrate mashumaro into
dbt to improve performance of 'from_dict' and 'to_dict'
`snowflake-connector-python` doesn't pin it, and it restricts us to a
much older version of boto3 than the boto3 pin would otherwise allow
(specifically, botocore<1.15 requires boto3<1.12).
Related: #2197
The currently postgres `make_temp_relation` adds a 29 character suffix to the end of the temp relation identifier (9 from default suffix and 20 from timestamp). This is a problem now that relations with more than 63 characters raise exceptions.
The fix is to shorten the suffix and also trim the base_relation identifier so that the total length is always less than 63 characters.
An exception can also be raised if the default suffix is overridden with a value that is too long.
Add ParsedReport/UnparsedReport
add report parser and report node logic to manifest/results/dbt ls/selectors
NonSourceNode -> ManifestNode
add GraphMemberNode type that includes reports
remove unused test folders
move rpc tests from 048 to 100 for convenience
- Migrating these to the test/rpc model is going to take work. In the
interim, developers can now use `tests/integeration/0*` to run all non-rpc
tests.
See https://github.com/fishtown-analytics/dbt/issues/2739
This change enables Linux users to run the dbt tests via the docker
image. It follows the recommendations from this article:
https://jtreminio.com/blog/running-docker-containers-as-current-host-user/
Notable changes:
* Added new Makefile rule to generate a .env file that contains USER_ID
and GROUP_ID environment variables to the ID of the current user. This
is in turn used by docker-compose and the Dockerfile to make the Docker
image run as the current user. (Note that on Windows or Mac, this
behavior happens by default).
* Reordered Dockerfile to allow for better caching of intermediate
images (i.e., put things that don't depend on ARGS earlier).
* Bumped CircleCI's Dockerfile from version 7 to 9. Jake rebuilt
9 off of this PR.
**Introduction**
This PR attempts to fix#2347, wherein we wish `dbt` to complain about trying to install with a Python version < 3.6.
**Changes**
Per [the issue's suggestion](https://github.com/fishtown-analytics/dbt/issues/2347), I found every `setup.py` file I could:
```
-# If you have the fantastic `fd` utility installed:
fd setup.py
-# This also works
find . -name setup.py -print
```
Then to each of these, I added the following after the `import sys`:
```
if sys.version_info < (3, 6):
print('Error: dbt does not support this version of Python.')
print('Please upgrade to Python 3.6 or higher.')
sys.exit(1)
```
**Testing**
I used the [`nix` package manager](https://nixos.org) to attempt installing this branch with both Python 2.7 and Python 3.8.
_Python 2.7_ fails as expected:
```
~/github/test2 ∃ cat default.nix
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz") { };
py = pkgs.python27Full.withPackages (p: [ p.setuptools ]);
in pkgs.mkShell {
name = "python-2-env";
buildInputs = [ py ];
}
~/github/test2 ∃ nix-shell --pure
[nix-shell:~/github/test2]$ python ../dbt/setup.py build
Error: dbt does not support this version of Python.
Please upgrade to Python 3.6 or higher.
[nix-shell:~/github/test2]$ echo $?
1
```
_Python 3.8_ still works:
```
~/github/test3 ∃ cat default.nix
let
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/20.03.tar.gz") { };
py = pkgs.python38Full.withPackages (p: [ p.setuptools ]);
in pkgs.mkShell {
name = "python-3-env";
buildInputs = [ py ];
}
~/github/test3 ∃ nix-shell --pure
[nix-shell:~/github/test3]$ python ../dbt/setup.py build
running build
[nix-shell:~/github/test3]$ echo $?
0
```
The adapter's Relation is consulted for adding the ephemeral model prefix
Also hide some things from Jinja
Have the adapter be responsible for producing the compiler, move CTE generation into the Relation object
- Actually set deferred=True
- add a test for that
- combine/unify environment vars vs cli vars behavior between defer/state better
- make the state path start with DBT_
- close() implies rollback, so do not call it
- make sure to not open new connections for executors in single-threaded mode
- logging cleanups
- fix a test case that never acquired connections
- to cancel other connections, one must first acquire a connection for the master thread
- change a number of release() calls to rollback
release vs rollback
- moved what remains of the linker into compilation, migrate things to the graph
- compile uncompiled ephemeral models when prepending ctes
- no more including them all in the selection
- per-node task selectors
- added the idea of a selection spec, graph selection uses that
- right now we parse include + exclude strings
Moved some relation logic out of adapters and into contracts
Fixed a typo in a type name
Fixed an issue where tests could fail based on color settings
Fixed the type analysis for adapter plugins/factory
Swapped more concrete tyeps out for protocols
Finally removed PACKAGES global
Added unit tests
consolidate dbt.ui, move non-rpc node_runners into their tasks
move parse_cli_vars into config.utils
get rid of logger/exceptions requirements in dbt.utils
- Add selector method when reading selector definitions ([#4821](https://github.com/dbt-labs/dbt-core/issues/4821), [#4827](https://github.com/dbt-labs/dbt-core/pull/4827))
- Add set and zip function to contexts ([#2345](https://github.com/dbt-labs/dbt-core/issues/2345), [#5107](https://github.com/dbt-labs/dbt-core/pull/5107))
- Adds itertools to modules Jinja namespace ([#5130](https://github.com/dbt-labs/dbt-core/issues/5130), [#5140](https://github.com/dbt-labs/dbt-core/pull/5140))
- allow target as an option in profile_template.yml ([#5179](https://github.com/dbt-labs/dbt-core/issues/5179), [#5184](https://github.com/dbt-labs/dbt-core/pull/5184))
- seed: Add new macro get_csv_sql ([#5206](https://github.com/dbt-labs/dbt-core/issues/5206), [#5207](https://github.com/dbt-labs/dbt-core/pull/5207))
- Grants as Node Configs ([#5189](https://github.com/dbt-labs/dbt-core/issues/5189), [#5230](https://github.com/dbt-labs/dbt-core/pull/5230))
- Adds file selectors and support for file selectors in the default method selector ([#5240](https://github.com/dbt-labs/dbt-core/issues/5240), [#5241](https://github.com/dbt-labs/dbt-core/pull/5241))
- Move cross-db macros from dbt-utils into dbt-core global project ([#4813](https://github.com/dbt-labs/dbt-core/issues/4813), [#5265](https://github.com/dbt-labs/dbt-core/pull/5265))
- Prettify duration message at the end of execution ([#5253](https://github.com/dbt-labs/dbt-core/issues/5253), [#5364](https://github.com/dbt-labs/dbt-core/pull/5364))
- Early return from dbt init if no available adapters ([#5365](https://github.com/dbt-labs/dbt-core/issues/5365), [#5366](https://github.com/dbt-labs/dbt-core/pull/5366))
- Allow customizing `target-path` and `log-path` through environment variables and CLI flags. ([#5399](https://github.com/dbt-labs/dbt-core/issues/5399), [#5402](https://github.com/dbt-labs/dbt-core/pull/5402))
- Move type_* macros from dbt-utils into dbt-core, with tests ([#5317](https://github.com/dbt-labs/dbt-core/issues/5317), [#5428](https://github.com/dbt-labs/dbt-core/pull/5428))
- Add support for ratio metrics ([#4884](https://github.com/dbt-labs/dbt-core/issues/4884), [#5027](https://github.com/dbt-labs/dbt-core/pull/5027))
- Allow users to define grants as a reasonable default in the dbt_project.yml or within each model sql or yml file combined. ([#5263](https://github.com/dbt-labs/dbt-core/issues/5263), [#5369](https://github.com/dbt-labs/dbt-core/pull/5369))
- Add reusable function for retrying adapter connections. Utilize said function to add retries for Postgres (and Redshift). ([#5022](https://github.com/dbt-labs/dbt-core/issues/5022), [#5432](https://github.com/dbt-labs/dbt-core/pull/5432))
### Fixes
- Adding new cols to check_cols in snapshots ([#3146](https://github.com/dbt-labs/dbt-core/issues/3146), [#4893](https://github.com/dbt-labs/dbt-core/pull/4893))
- Truncate relation names when appending a suffix that will result in len > 63 characters using make_temp_relation and make_backup_relation macros ([#2869](https://github.com/dbt-labs/dbt-core/issues/2869), [#4921](https://github.com/dbt-labs/dbt-core/pull/4921))
- Restore ability to utilize `updated_at` for check_cols snapshots ([#5076](https://github.com/dbt-labs/dbt-core/issues/5076), [#5077](https://github.com/dbt-labs/dbt-core/pull/5077))
- Use yaml renderer (with target context) for rendering selectors ([#5131](https://github.com/dbt-labs/dbt-core/issues/5131), [#5136](https://github.com/dbt-labs/dbt-core/pull/5136))
- Fix retry logic to return values after initial try ([#5023](https://github.com/dbt-labs/dbt-core/issues/5023), [#5137](https://github.com/dbt-labs/dbt-core/pull/5137))
- Scrub secret env vars from CommandError in exception stacktrace ([#5151](https://github.com/dbt-labs/dbt-core/issues/5151), [#5152](https://github.com/dbt-labs/dbt-core/pull/5152))
- Ensure the metric name does not contain spaces ([#4572](https://github.com/dbt-labs/dbt-core/issues/4572), [#5173](https://github.com/dbt-labs/dbt-core/pull/5173))
- When parsing 'all_sources' should be a list of unique dirs ([#5120](https://github.com/dbt-labs/dbt-core/issues/5120), [#5176](https://github.com/dbt-labs/dbt-core/pull/5176))
- Add warning if yaml contains duplicate keys ([#5114](https://github.com/dbt-labs/dbt-core/issues/5114), [#5146](https://github.com/dbt-labs/dbt-core/pull/5146))
- Modifying the drop_test_schema to work better with Redshift issues around locked tables and current transactions ([#5200](https://github.com/dbt-labs/dbt-core/issues/5200), [#5198](https://github.com/dbt-labs/dbt-core/pull/5198))
- Fix column comparison in snapshot_check_all_get_existing_columns for check-strategy snapshots with explicit check_cols defined ([#5222](https://github.com/dbt-labs/dbt-core/issues/5222), [#5223](https://github.com/dbt-labs/dbt-core/pull/5223))
- Changed how `--select state:modified` detects changes for macros nodes depend on ([#5202](https://github.com/dbt-labs/dbt-core/issues/5202), [#5224](https://github.com/dbt-labs/dbt-core/pull/5224))
- Fix column comparison in snapshot_check_all_get_existing_columns to use adapter.get_columns_in_relation ([#5222](https://github.com/dbt-labs/dbt-core/issues/5222), [#5232](https://github.com/dbt-labs/dbt-core/pull/5232))
- Remove docs file from manifest when removing doc node ([#4146](https://github.com/dbt-labs/dbt-core/issues/4146), [#5270](https://github.com/dbt-labs/dbt-core/pull/5270))
- Change node ancestor/descendant algo, fixes issue where downstream models aren't run when using networkx >= 2.8.1 ([#5286](https://github.com/dbt-labs/dbt-core/issues/5286), [#5326](https://github.com/dbt-labs/dbt-core/pull/5326))
- Fixing Windows color regression ([#5191](https://github.com/dbt-labs/dbt-core/issues/5191), [#5327](https://github.com/dbt-labs/dbt-core/pull/5327))
- Define compatibility for older manifest versions when using state: selection methods ([#5213](https://github.com/dbt-labs/dbt-core/issues/5213), [#5346](https://github.com/dbt-labs/dbt-core/pull/5346))
- Add inheritance to materialization macro resolution ([#4646](https://github.com/dbt-labs/dbt-core/issues/4646), [#5348](https://github.com/dbt-labs/dbt-core/pull/5348))
- Improve pluralizations for Documentation and SqlOperation NodeTypes ([#5352](https://github.com/dbt-labs/dbt-core/issues/5352), [#5356](https://github.com/dbt-labs/dbt-core/pull/5356))
- Properly use quotes for Snowflake snapshots when checking all columns ([#2975](https://github.com/dbt-labs/dbt-core/issues/2975), [#5389](https://github.com/dbt-labs/dbt-core/pull/5389))
- fixes handling of RESET color code with USE_COLORS=False ([#5288](https://github.com/dbt-labs/dbt-core/issues/5288), [#5394](https://github.com/dbt-labs/dbt-core/pull/5394))
- Remove duplicate key checking introduced in 1.2.0a1 ([#5331](https://github.com/dbt-labs/dbt-core/issues/5331), [#5403](https://github.com/dbt-labs/dbt-core/pull/5403))
- Rename try to strict for more intuitiveness ([#5475](https://github.com/dbt-labs/dbt-core/issues/5475), [#5477](https://github.com/dbt-labs/dbt-core/pull/5477))
### Docs
- Fixed sample SQL Code for sources when no database is defined ([#5255](https://github.com/dbt-labs/dbt-core/issues/5255), [#5446](https://github.com/dbt-labs/dbt-core/pull/5446))
- Add support for `file:` selector in DAG viz ([#5255](https://github.com/dbt-labs/dbt-core/issues/5255), [#5446](https://github.com/dbt-labs/dbt-core/pull/5446))
- [Snyk] Upgrade prismjs from 1.27.0 to 1.28.0 ([#5255](https://github.com/dbt-labs/dbt-core/issues/5255), [#5446](https://github.com/dbt-labs/dbt-core/pull/5446))
- Run build and tests in CI checks ([#5255](https://github.com/dbt-labs/dbt-core/issues/5255), [#5446](https://github.com/dbt-labs/dbt-core/pull/5446))
- Improve metrics DAG viz and documentation page ([#5255](https://github.com/dbt-labs/dbt-core/issues/5255), [#5446](https://github.com/dbt-labs/dbt-core/pull/5446))
- Migrating 005_simple_seed to the new test framework. ([#200](https://github.com/dbt-labs/dbt-core/issues/200), [#5013](https://github.com/dbt-labs/dbt-core/pull/5013))
- Convert 029_docs_generate tests to new framework ([#5035](https://github.com/dbt-labs/dbt-core/issues/5035), [#5058](https://github.com/dbt-labs/dbt-core/pull/5058))
- removal of scaffold first attempt and create_adapter_plugin.py as they are deprecated new scaffold can be found https://github.com/dbt-labs/dbt-database-adapter-scaffold ([#4980](https://github.com/dbt-labs/dbt-core/issues/4980), [#5117](https://github.com/dbt-labs/dbt-core/pull/5117))
- Mypy -> 0.942 + fixed import logic to allow for full mypy coverage ([#4805](https://github.com/dbt-labs/dbt-core/issues/4805), [#5171](https://github.com/dbt-labs/dbt-core/pull/5171))
- Converted dbt list tests to pytest ([#5049](https://github.com/dbt-labs/dbt-core/issues/5049), [#5178](https://github.com/dbt-labs/dbt-core/pull/5178))
- Fix: Call str and repr for UnsetProfileConfig without a RuntimeException ([#5081](https://github.com/dbt-labs/dbt-core/issues/5081), [#5209](https://github.com/dbt-labs/dbt-core/pull/5209))
- Clean up materialization logic: more consistent relation names, loading from cache ([#2869](https://github.com/dbt-labs/dbt-core/issues/2869), [#4921](https://github.com/dbt-labs/dbt-core/pull/4921))
- Use the default Python version for local dev and test instead of requiring Python 3.8 ([#5257](https://github.com/dbt-labs/dbt-core/issues/5257), [#5269](https://github.com/dbt-labs/dbt-core/pull/5269))
- Fix test for context set function ([#5266](https://github.com/dbt-labs/dbt-core/issues/5266), [#5272](https://github.com/dbt-labs/dbt-core/pull/5272))
- Fix pip upgrade step in CI for Windows ([#5321](https://github.com/dbt-labs/dbt-core/issues/5321), [#5320](https://github.com/dbt-labs/dbt-core/pull/5320))
- Fix unit test test_graph_selection ([#5323](https://github.com/dbt-labs/dbt-core/issues/5323), [#5324](https://github.com/dbt-labs/dbt-core/pull/5324))
- removed script meant for snowflake to snowflake ([#5361](https://github.com/dbt-labs/dbt-core/issues/5361), [#5362](https://github.com/dbt-labs/dbt-core/pull/5362))
- Added the suggested RegEx to check the SemVer string within a package dependency and improved invalid version error handling. ([#5201](https://github.com/dbt-labs/dbt-core/issues/5201), [#5370](https://github.com/dbt-labs/dbt-core/pull/5370))
- Add annotation to render_value method reimplemented in #5334 ([#4796](https://github.com/dbt-labs/dbt-core/issues/4796), [#5382](https://github.com/dbt-labs/dbt-core/pull/5382))
- Bump manifest version to v6 ([#5417](https://github.com/dbt-labs/dbt-core/issues/5417), [#5430](https://github.com/dbt-labs/dbt-core/pull/5430))
- Add tests for SQL grants ([#5437](https://github.com/dbt-labs/dbt-core/issues/5437), [#5447](https://github.com/dbt-labs/dbt-core/pull/5447))
### Dependencies
- Bump ubuntu from 20.04 to 22.04 ([#4904](https://github.com/dbt-labs/dbt-core/issues/4904), [#5141](https://github.com/dbt-labs/dbt-core/pull/5141))
- Bumping hologram version ([#5219](https://github.com/dbt-labs/dbt-core/issues/5219), [#5218](https://github.com/dbt-labs/dbt-core/pull/5218))
- Bump mypy from 0.942 to 0.961 ([#4904](https://github.com/dbt-labs/dbt-core/issues/4904), [#5337](https://github.com/dbt-labs/dbt-core/pull/5337))
- Bump python from 3.10.3-slim-bullseye to 3.10.5-slim-bullseye in /docker ([#4904](https://github.com/dbt-labs/dbt-core/issues/4904), [#5367](https://github.com/dbt-labs/dbt-core/pull/5367))
- Update colorama requirement from <0.4.5,>=0.3.9 to >=0.3.9,<0.4.6in/core([#4904](https://github.com/dbt-labs/dbt-core/issues/4904), [#5388](https://github.com/dbt-labs/dbt-core/pull/5388))
- Use sys.exit instead of exit ([#5621](https://github.com/dbt-labs/dbt-core/issues/5621), [#5627](https://github.com/dbt-labs/dbt-core/pull/5627))
- Finishing logic upgrade to Redshift for name truncation collisions. ([#5586](https://github.com/dbt-labs/dbt-core/issues/5586), [#5656](https://github.com/dbt-labs/dbt-core/pull/5656))
- This conditionally no-ops warehouse connection at compile depending on an env var, disabling introspection/queries during compilation only. This is a temporary solution to more complex permissions requirements for the semantic layer. ([#5936](https://github.com/dbt-labs/dbt-core/issues/5936), [#5926](https://github.com/dbt-labs/dbt-core/pull/5926))
### Fixes
- Fix race condition when invoking dbt via lib.py concurrently ([#5919](https://github.com/dbt-labs/dbt-core/issues/5919), [#5921](https://github.com/dbt-labs/dbt-core/pull/5921))
- This pulls the profile name from args when constructing a RuntimeConfig in lib.py, enabling the dbt-server to override the value that's in the dbt_project.yml ([#6201](https://github.com/dbt-labs/dbt-core/issues/6201), [#6202](https://github.com/dbt-labs/dbt-core/pull/6202))
- Bug when partial parsing with an empty schema file ([#4850](https://github.com/dbt-labs/dbt-core/issues/4850), [#<no value>](https://github.com/dbt-labs/dbt-core/pull/<no value>))
We use [changie](https://changie.dev/) to automate `CHANGELOG` generation. For installation and format/command specifics, see the documentation.
### Quick Tour
- All new change entries get generated under `/.changes/unreleased` as a yaml file
-`header.tpl.md` contains the contents of the entire CHANGELOG file
-`0.0.0.md` contains the contents of the footer for the entire CHANGELOG file. changie looks to be in the process of supporting a footer file the same as it supports a header file. Switch to that when available. For now, the 0.0.0 in the file name forces it to the bottom of the changelog no matter what version we are releasing.
-`.changie.yaml` contains the fields in a change, the format of a single change, as well as the format of the Contributors section for each version.
### Workflow
#### Daily workflow
Almost every code change we make associated with an issue will require a `CHANGELOG` entry. After you have created the PR in GitHub, run `changie new` and follow the command prompts to generate a yaml file with your change details. This only needs to be done once per PR.
The `changie new` command will ensure correct file format and file name. There is a one to one mapping of issues to changes. Multiple issues cannot be lumped into a single entry. If you make a mistake, the yaml file may be directly modified and saved as long as the format is preserved.
Note: If your PR has been cleared by the Core Team as not needing a changelog entry, the `Skip Changelog` label may be put on the PR to bypass the GitHub action that blacks PRs from being merged when they are missing a `CHANGELOG` entry.
#### Prerelease Workflow
These commands batch up changes in `/.changes/unreleased` to be included in this prerelease and move those files to a directory named for the release version. The `--move-dir` will be created if it does not exist and is created in `/.changes`.
These commands batch up changes in `/.changes/unreleased` as well as `/.changes/<version>` to be included in this final release and delete all prereleases. This rolls all prereleases up into a single final release. All `yaml` files in `/unreleased` and `<version>` will be deleted at this point.
- Changie generates markdown files in the `.changes` directory that are parsed together with the `changie merge` command. Every time `changie merge` is run, it regenerates the entire file. For this reason, any changes made directly to `CHANGELOG.md` will be overwritten on the next run of `changie merge`.
- If changes need to be made to the `CHANGELOG.md`, make the changes to the relevant `<version>.md` file located in the `/.changes` directory. You will then run `changie merge` to regenerate the `CHANGELOG.MD`.
- Do not run `changie batch` again on released versions. Our final release workflow deletes all of the yaml files associated with individual changes. If for some reason modifications to the `CHANGELOG.md` are required after we've generated the final release `CHANGELOG.md`, the modifications need to be done manually to the `<version>.md` file in the `/.changes` directory.
- changie can modify, create and delete files depending on the command you run. This is expected. Be sure to commit everything that has been modified and deleted.
- This file provides a full account of all changes to `dbt-core` and `dbt-postgres`
- Changes are listed under the (pre)release in which they first appear. Subsequent releases include changes from previous releases.
- "Breaking changes" listed under a version may require action from end users or external maintainers when upgrading to that version.
- Do not edit this file directly. This file is auto-generated using [changie](https://github.com/miniscruff/changie). For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry)
about: Report a bug or an issue you've found with dbt
title: ''
labels: bug, triage
assignees: ''
---
### Describe the bug
A clear and concise description of what the bug is. What command did you run? What happened?
### Steps To Reproduce
In as much detail as possible, please provide steps to reproduce the issue. Sample data that triggers the issue, example model code, etc is all very helpful here.
### Expected behavior
A clear and concise description of what you expected to happen.
### Screenshots and log output
If applicable, add screenshots or log output to help explain your problem.
# Github package 'latest' tag wrangler for containers
## Usage
Plug in the necessary inputs to determine if the container being built should be tagged 'latest; at the package level, for example `dbt-redshift:latest`.
## Inputs
| Input | Description |
| - | - |
| `package` | Name of the GH package to check against |
| `new_version` | Semver of new container |
| `gh_token` | GH token with package read scope|
| `halt_on_missing` | Return non-zero exit code if requested package does not exist. (defaults to false)|
## Outputs
| Output | Description |
| - | - |
| `latest` | Wether or not the new container should be tagged 'latest'|
| `minor_latest` | Wether or not the new container should be tagged major.minor.latest |
Include the number of the issue addressed by this PR above if applicable.
PRs for code changes without an associated issue*will not be merged*.
See CONTRIBUTING.md for more information.
Example:
resolves #1234
-->
### Description
<!--- Describe the Pull Request here -->
<!---
Describe the Pull Request here. Add any references and info to help reviewers
understand your changes. Include any tradeoffs you considered.
-->
### Checklist
- [ ] I have signed the [CLA](https://docs.getdbt.com/docs/contributor-license-agreements)
- [ ] I have run this code in development and it appears to resolve the stated issue
- [ ]This PR includes tests, or tests are not required/relevant for this PR
- [ ] I have updated the `CHANGELOG.md` and added information about my change to the "dbt next" section.
- [ ] I have read [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md) and understand what's expected of me
- [ ]I have signed the [CLA](https://docs.getdbt.com/docs/contributor-license-agreements)
- [ ] I have run this code in development and it appears to resolve the stated issue
- [ ] This PR includes tests, or tests are not required/relevant for this PR
- [ ] I have [opened an issue to add/update docs](https://github.com/dbt-labs/docs.getdbt.com/issues/new/choose), or docs changes are not required/relevant for this PR
- [ ] I have run `changie new` to [create a changelog entry](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#Adding-CHANGELOG-Entry)
changelog_comment:'Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see [the contributing guide](https://github.com/dbt-labs/dbt-core/blob/main/CONTRIBUTING.md#adding-changelog-entry).'
stale-issue-message:"This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please remove the stale label or comment on the issue, or it will be closed in 7 days."
stale-pr-message:"This PR has been marked as Stale because it has been open for 180 days with no activity. If you would like the PR to remain open, please remove the stale label or comment on the PR, or it will be closed in 7 days."
close-issue-message:"Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest; add a comment to notify the maintainers."
# mark issues/PRs stale when they haven't seen activity in 180 days
The core function of dbt is SQL compilation and execution. Users create projects of dbt resources (models, tests, seeds, snapshots, ...), defined in SQL and YAML files, and they invoke dbt to create, update, or query associated views and tables. Today, dbt makes heavy use of Jinja2 to enable the templating of SQL, and to construct a DAG (Directed Acyclic Graph) from all of the resources in a project. Users can also extend their projects by installing resources (including Jinja macros) from other projects, called "packages."
## dbt-core
Most of the python code in the repository is within the `core/dbt` directory.
- [`single python files`](core/dbt/README.md): A number of individual files, such as 'compilation.py' and 'exceptions.py'
The main subdirectories of core/dbt:
- [`adapters`](core/dbt/adapters/README.md): Define base classes for behavior that is likely to differ across databases
- [`clients`](core/dbt/clients/README.md): Interface with dependencies (agate, jinja) or across operating systems
- [`config`](core/dbt/config/README.md): Reconcile user-supplied configuration from connection profiles, project files, and Jinja macros
- [`context`](core/dbt/context/README.md): Build and expose dbt-specific Jinja functionality
- [`contracts`](core/dbt/contracts/README.md): Define Python objects (dataclasses) that dbt expects to create and validate
- [`deps`](core/dbt/deps/README.md): Package installation and dependency resolution
The "tasks" map to top-level dbt commands. So `dbt run` => task.run.RunTask, etc. Some are more like abstract base classes (GraphRunnableTask, for example) but all the concrete types outside of task should map to tasks. Currently one executes at a time. The tasks kick off their “Runners” and those do execute in parallel. The parallelism is managed via a thread pool, in GraphRunnableTask.
core/dbt/include/index.html
This is the docs website code. It comes from the dbt-docs repository, and is generated when a release is packaged.
## Adapters
dbt uses an adapter-plugin pattern to extend support to different databases, warehouses, query engines, etc. For testing and development purposes, the dbt-postgres plugin lives alongside the dbt-core codebase, in the [`plugins`](plugins) subdirectory. Like other adapter plugins, it is a self-contained codebase and package that builds on top of dbt-core.
Each adapter is a mix of python, Jinja2, and SQL. The adapter code also makes heavy use of Jinja2 to wrap modular chunks of SQL functionality, define default implementations, and allow plugins to override it.
Each adapter plugin is a standalone python package that includes:
-`dbt/include/[name]`: A "sub-global" dbt project, of YAML and SQL files, that reimplements Jinja macros to use the adapter's supported SQL syntax
-`dbt/adapters/[name]`: Python modules that inherit, and optionally reimplement, the base adapter classes defined in dbt-core
-`setup.py`
The Postgres adapter code is the most central, and many of its implementations are used as the default defined in the dbt-core global project. The greater the distance of a data technology from Postgres, the more its adapter plugin may need to reimplement.
## Testing dbt
The [`test/`](test/) subdirectory includes unit and integration tests that run as continuous integration checks against open pull requests. Unit tests check mock inputs and outputs of specific python functions. Integration tests perform end-to-end dbt invocations against real adapters (Postgres, Redshift, Snowflake, BigQuery) and assert that the results match expectations. See [the contributing guide](CONTRIBUTING.md) for a step-by-step walkthrough of setting up a local development and testing environment.
## Everything else
- [docker](docker/): All dbt versions are published as Docker images on DockerHub. This subfolder contains the `Dockerfile` (constant) and `requirements.txt` (one for each version).
- [etc](etc/): Images for README
- [scripts](scripts/): Helper scripts for testing, releasing, and producing JSON schemas. These are not included in distributions of dbt, nor are they rigorously tested—they're just handy tools for the dbt maintainers :)
`dbt-core` is open source software. It is what it is today because community members have opened issues, provided feedback, and [contributed to the knowledge loop](https://www.getdbt.com/dbt-labs/values/). Whether you are a seasoned open source contributor or a first-time committer, we welcome and encourage you to contribute code, documentation, ideas, or problem statements to this project.
1. [About this document](#about-this-document)
2. [Getting the code](#getting-the-code)
3. [Setting up an environment](#setting-up-an-environment)
4. [Running `dbt` in development](#running-dbt-core-in-development)
5. [Testing dbt-core](#testing)
6. [Submitting a Pull Request](#submitting-a-pull-request)
## About this document
This document is a guide intended for folks interested in contributing to dbt. It is not intended as a guide for end users of dbt (though if it is helpful, that's great!) and it assumes a certain level of familiarity with Python concepts such as virtualenvs, `pip`, python modules, filesystems, and so on. This guide also documents the process by which community-contributed Pull Requests can be incorporated into this repository. This guide assumes you are using macOS or Linux and are comfortable with the command line. If you get stuck while reading this guide, drop us a line in the #development channel on [slack](slack.getdbt.com).
There are many ways to contribute to the ongoing development of `dbt-core`, such as by participating in discussions and issues. We encourage you to first read our higher-level document: ["Expectations for Open Source Contributors"](https://docs.getdbt.com/docs/contributing/oss-expectations).
## Contributing a change
The rest of this document serves as a more granular guide for contributing code changes to `dbt-core` (this repository). It is not intended as a guide for using `dbt-core`, and some pieces assume a level of familiarity with Python development (virtualenvs, `pip`, etc). Specific code snippets in this guide assume you are using macOS or Linux and are comfortable with the command line.
dbt is Apache 2.0-licensed open source software. dbt is the software that it is today because community members like you have opened issues, provided feedback, and contributed to the knowledge loop for the entire communtiy. Whether you are a seasoned open source contributor or a first time committer, you are welcomed and encouraged to contribute code, documentation, ideas, or problem statements to this project.
If you get stuck, we're happy to help! Drop us a line in the `#dbt-core-development` channel in the [dbt Community Slack](https://community.getdbt.com).
### Defining the problem
If you have an idea for a new feature or if you've discovered a bug in dbt, the first step is to open an issue. Please check the list of [open issues](https://github.com/fishtown-analytics/dbt/issues) before creating a new one. If you find a relevant issue, please add a comment to the open issue instead of creating a new one. There are hundreds of open issues in this repository and it can be hard to know where to look for a relevant open issue. **The dbt maintainers are always happy to point contributors in the right direction**, so please err on the side of documenting your idea in a new issue if you are unsure where a problem statement belongs.
**Note:** All community-contributed Pull Requests _must_ be associated with an open issue. If you submit a Pull Request that does not pertain to an open issue, you will be asked to create an issue describing the problem before the Pull Request can be reviewed.
### Discussing the idea
After creating an issue, a dbt maintainer will follow up with you to explore your idea further and advise on how to implement the suggested changes. In many cases, community members will chime in with their own thoughts on the problem statement. If you as the issue creator are interested in submitting a Pull Request to address the issue, you should indicate this in the body of the issue. The dbt maintainers are _always_ happy to help contributors with the implementation of fixes and features, so please also indicate if there's anything you're unsure about or could use guidance around in the issue.
### Submitting a change
If the issue is appropriately well-scoped and describes a beneficial change to the dbt codebase, then anyone may submit a Pull Request to implement the functionality described in the issue (see the sections below on how to do this).
In some cases, the right resolution to an open issue might be tangential to the dbt codebase. The right path forward might be a documentation update or a change that can be made in user-space. In other cases, the issue might describe functionality that the dbt maintainers are unwilling or unable to incorporate into the dbt codebase. When it is determined that an open issue describes functionality that will not translate to a code change in the dbt repository, the issue will be tagged with the `wontfix` label (see below) and closed.
### Using issue labels
The dbt maintainers use labels to categorize open issues. Some labels indicate the databases impacted by the issue, while others describe the domain in the dbt codebase germane to the discussion. While most of these labels are self-explanatory (eg. `snowflake` or `bigquery`), there are others that are worth describing.
| tag | description |
| --- | ----------- |
| bug | This issue represents a defect or regression in dbt |
| enhancement | This issue represents net-new functionality in dbt |
| good first issue | This issue does not require deep knowledge of the dbt codebase to implement. This issue is appropriate for a first-time contributor to implement. |
| snoozed | This issue describes a good idea, but one which will probably not be addressed in a six-month time horizon. The dbt maintainers will revist these issues periodically and re-prioritize them accordingly. |
| triage | This is a new issue which has not yet been reviewed by a dbt maintainer. This label is removed when a maintainer reviews and responds to the issue. |
| stale | This is an old issue which has not recently been updated. Stale issues will periodically be closed by dbt maintainers, but they can be re-opened if the discussion is restarted. |
| wontfix | This issue does not require a code change in the dbt repository, or the maintainers are unwilling/unable to merge a Pull Request which implements the behavior described in the issue. |
### Signing the CLA
All contributors to dbt must sign the [Contributor License Agreement](https://docs.getdbt.com/docs/contributor-license-agreements) to have their Pull Request merged into the dbt codebase. If you are unable to sign the CLA, then the dbt maintainers will unfortunately be unable to merge your Pull Request.
### Notes
- **Adapters:** Is your issue or proposed code change related to a specific [database adapter](https://docs.getdbt.com/docs/available-adapters)? If so, please open issues, PRs, and discussions in that adapter's repository instead. The sole exception is Postgres; the `dbt-postgres` plugin lives in this repository (`dbt-core`).
- **CLA:** Please note that anyone contributing code to `dbt-core` must sign the [Contributor License Agreement](https://docs.getdbt.com/docs/contributor-license-agreements). If you are unable to sign the CLA, the `dbt-core` maintainers will unfortunately be unable to merge any of your Pull Requests. We welcome you to participate in discussions, open issues, and comment on existing ones.
- **Branches:** All pull requests from community contributors should target the `main` branch (default). If the change is needed as a patch for a minor version of dbt that has already been released (or is already a release candidate), a maintainer will backport the changes in your PR to the relevant "latest" release branch (`1.0.latest`, `1.1.latest`, ...)
## Getting the code
### Installing git
You will need `git` in order to download and modify the dbt source code. On macOS, the best way to download git is to just install Xcode.
You will need `git` in order to download and modify the `dbt-core` source code. On macOS, the best way to download git is to just install [Xcode](https://developer.apple.com/support/xcode/).
### External contributors
If you are not a member of the `fishtown-analytics` GitHub organization, you can contribute to dbt by forking the dbt repository. For a detailed overview on forking, check out the [GitHub docs on forking](https://help.github.com/en/articles/fork-a-repo). In short, you will need to:
If you are not a member of the `dbt-labs` GitHub organization, you can contribute to `dbt-core` by forking the `dbt-core` repository. For a detailed overview on forking, check out the [GitHub docs on forking](https://help.github.com/en/articles/fork-a-repo). In short, you will need to:
1.fork the dbt repository
2.clone your fork
3.check out a new branch for your proposed changes
4.push changes to your fork
5.open a pull request against `fishtown-analytics/dbt` from your forked repository
1.Fork the `dbt-core` repository
2.Clone your fork locally
3.Check out a new branch for your proposed changes
4.Push changes to your fork
5.Open a pull request against `dbt-labs/dbt-core` from your forked repository
### Core contributors
If you are a member of the `fishtown-analytics` GitHub organization, you will have push access to the dbt repo. Rather than
forking dbt to make your changes, just clone the repository and push directly to a branch.
### dbt Labs contributors
If you are a member of the `dbt-labs` GitHub organization, you will have push access to the `dbt-core` repo. Rather than forking `dbt-core` to make your changes, just clone the repository, check out a new branch, and push directly to that branch.
## Setting up an environment
To begin developing code in dbt, you should set up the following:
There are some tools that will be helpful to you in developing locally. While this is the list relevant for `dbt-core` development, many of these tools are used commonly across open-source python projects.
### virtualenv
### Tools
We strongly recommend using virtual environments when developing code in dbt. We recommend creating this virtualenv
in the root of the dbt repository. To create a new virtualenv, run:
```
These are the tools used in `dbt-core` development and testing:
- [`tox`](https://tox.readthedocs.io/en/latest/) to manage virtualenvs across python versions. We currently target the latest patch releases for Python 3.7, 3.8, 3.9, and 3.10
- [`pytest`](https://docs.pytest.org/en/latest/) to define, discover, and run tests
- [`flake8`](https://flake8.pycqa.org/en/latest/) for code linting
- [`black`](https://github.com/psf/black) for code formatting
- [`mypy`](https://mypy.readthedocs.io/en/stable/) for static type checking
- [`pre-commit`](https://pre-commit.com) to easily run those checks
- [`changie`](https://changie.dev/) to create changelog entries, without merge conflicts
- [`make`](https://users.cs.duke.edu/~ola/courses/programming/Makefiles/Makefiles.html) to run multiple setup or test steps in combination. Don't worry too much, nobody _really_ understands how `make` works, and our Makefile aims to be super simple.
- [GitHub Actions](https://github.com/features/actions) for automating tests and checks, once a PR is pushed to the `dbt-core` repository
A deep understanding of these tools in not required to effectively contribute to `dbt-core`, but we recommend checking out the attached documentation if you're interested in learning more about each one.
#### Virtual environments
We strongly recommend using virtual environments when developing code in `dbt-core`. We recommend creating this virtualenv
in the root of the `dbt-core` repository. To create a new virtualenv, run:
```sh
python3 -m venv env
source env/bin/activate
```
This will create and activate a new Python virtual environment.
### docker and docker-compose
#### Docker and `docker-compose`
Docker and docker-compose are both used in testing. For macOS, the easiest thing to do is to [download docker for mac](https://store.docker.com/editions/community/docker-ce-desktop-mac). You'll need to make an account. On Linux, you can use one of the packages [here](https://docs.docker.com/install/#server). We recommend installing from docker.com instead of from your package manager. On Linux you also have to install docker-compose separately, follow [these instructions](https://docs.docker.com/compose/install/#install-compose).
Docker and `docker-compose` are both used in testing. Specific instructions for you OS can be found [here](https://docs.docker.com/get-docker/).
### Installing postgres locally (optional)
#### Postgres (optional)
For testing, and later in the examples in this document, you may want to have `psql` available so you can poke around in the database and see what happened. We recommend that you use [homebrew](https://brew.sh/) for that on macOS, and your package manager on Linux. You can install any version of the postgres client that you'd like. On macOS, with homebrew setup, you can run:
```
```sh
brew install postgresql
```
## Running dbt in development
## Running `dbt-core` in development
### Installation
First make sure that you set up your `virtualenv` as described in section _Settingupanenvironment_. Next, install dbt (and it's dependencies) with:
First make sure that you set up your `virtualenv` as described in [Setting up an environment](#setting-up-an-environment). Also ensure you have the latest version of pip installed with `pip install --upgrade pip`. Next, install `dbt-core` (and its dependencies) with:
When dbt is installed from source in this way, any changes you make to the dbt source code will be reflected immediately in your next `dbt` run.
When installed in this way, any changes you make to your local copy of the source code will be reflected immediately in your next `dbt` run.
### Running dbt
### Running `dbt-core`
With your virtualenv activated, the `dbt` script should point back to the source code you've cloned on your machine. You can verify this by running `which dbt`. This command should show you a path to an executable in your virtualenv.
Configure your [profile](https://docs.getdbt.com/docs/configure-your-profile) as necessary to connect to your target databases. It may be a good idea to add a new profile pointing to a local postgres instance, or a specific test sandbox within your data warehouse if appropriate.
Configure your [profile](https://docs.getdbt.com/docs/configure-your-profile) as necessary to connect to your target databases. It may be a good idea to add a new profile pointing to a local Postgres instance, or a specific test sandbox within your data warehouse if appropriate.
## Testing
Getting the dbt integration tests set up in your local environment will be very helpful as you start to make changes to your local version of dbt. The section that follows outlines some helpful tips for setting up the test environment.
Once you're able to manually test that your code change is working as expected, it's important to run existing automated tests, as well as adding some new ones. These tests will ensure that:
- Your code changes do not unexpectedly break other established functionality
- Your code changes can handle all known edge cases
- The functionality you're adding will _keep_ working in the future
### Tools
Although `dbt-core` works with a number of different databases, you won't need to supply credentials for every one of these databases in your test environment. Instead, you can test most `dbt-core` code changes with Python and Postgres.
A short list of tools used in dbt testing that will be helpful to your understanding:
### Initial setup
- [virtualenv](https://virtualenv.pypa.io/en/stable/) to manage dependencies
- [tox](https://tox.readthedocs.io/en/latest/) to manage virtualenvs across python versions
- [pytest](https://docs.pytest.org/en/latest/) to discover/run tests
- [make](https://users.cs.duke.edu/~ola/courses/programming/Makefiles/Makefiles.html) - but don't worry too much, nobody _really_ understands how make works and our Makefile is super simple
- [flake8](https://gitlab.com/pycqa/flake8) for code linting
- [CircleCI](https://circleci.com/product/) and [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/)
A deep understanding of these tools in not required to effectively contribute to dbt, but we recommend checking out the attached documentation if you're interested in learning more about them.
### Running tests via Docker
dbt's unit and integration tests run in Docker. Because dbt works with a number of different databases, you will need to supply credentials for one or more of these databases in your test environment. Most organizations don't have access to each of a BigQuery, Redshift, Snowflake, and Postgres database, so it's likely that you will be unable to run every integration test locally. Fortunately, Fishtown Analytics provides a CI environment with access to sandboxed Redshift, Snowflake, BigQuery, and Postgres databases. See the section on _Submitting a Pull Request_ below for more information on this CI setup.
#### Specifying your test credentials
dbt uses test credentials specified in a `test.env` file in the root of the repository. This `test.env` file is git-ignored, but please be _extra_ careful to never check in credentials or other sensitive information when developing against dbt. To create your `test.env` file, copy the provided sample file, then supply your relevant credentials:
```
cp test.env.sample test.env
atom test.env # supply your credentials
```
We recommend starting with dbt's Postgres tests. These tests cover most of the functionality in dbt, are the fastest to run, and are the easiest to set up. dbt's test suite runs Postgres in a Docker container, so no setup should be required to run these tests. If you additionally want to test Snowflake, Bigquery, or Redshift locally you'll need to get credentials and add them to the `test.env` file.
#### Running tests
dbt's unit tests and Python linter can be run with:
```
make test-unit
```
To run the Postgres + Python 3.6 integration tests, you'll have to do one extra step of setting up the test database:
Postgres offers the easiest way to test most `dbt-core` functionality today. They are the fastest to run, and the easiest to set up. To run the Postgres integration tests, you'll have to do one extra step of setting up the test database:
To run a quick test for Python3 integration tests on Postgres, you can run:
### Test commands
There are a few methods for running tests locally.
#### Makefile
There are multiple targets in the Makefile to run common test suites and code
checks, most notably:
```sh
# Runs unit tests with py38 and code checks in parallel.
make test
# Runs postgres integration tests with py38 in "fail fast" mode.
make integration
```
make test-quick
> These make targets assume you have a local installation of a recent version of [`tox`](https://tox.readthedocs.io/en/latest/) for unit/integration testing and pre-commit for code quality checks,
> unless you use choose a Docker container to run tests. Run `make help` for more info.
Check out the other targets in the Makefile to see other commonly used test
suites.
#### `pre-commit`
[`pre-commit`](https://pre-commit.com) takes care of running all code-checks for formatting and linting. Run `make dev` to install `pre-commit` in your local environment. Once this is done you can use any of the linter-based make targets as well as a git pre-commit hook that will ensure proper formatting and linting.
#### `tox`
[`tox`](https://tox.readthedocs.io/en/latest/) takes care of managing virtualenvs and install dependencies in order to run tests. You can also run tests in parallel, for example, you can run unit tests for Python 3.7, Python 3.8, Python 3.9, and Python 3.10 checks in parallel with `tox -p`. Also, you can run unit tests for specific python versions with `tox -e py37`. The configuration for these tests in located in `tox.ini`.
#### `pytest`
Finally, you can also run a specific test or group of tests using [`pytest`](https://docs.pytest.org/en/latest/) directly. With a virtualenv active and dev dependencies installed you can do things like:
# run specific Postgres integration tests (new way)
python3 -m pytest tests/functional/sources
```
To run tests for a specific database, invoke `tox` directly with the required flags:
```
# Run Postgres py36 tests
docker-compose run test tox -e integration-postgres-py36 -- -x
> See [pytest usage docs](https://docs.pytest.org/en/6.2.x/usage.html) for an overview of useful command-line options.
# Run Snowflake py36 tests
docker-compose run test tox -e integration-snowflake-py36 -- -x
## Adding CHANGELOG Entry
# Run BigQuery py36 tests
docker-compose run test tox -e integration-bigquery-py36 -- -x
We use [changie](https://changie.dev) to generate `CHANGELOG` entries. **Note:** Do not edit the `CHANGELOG.md` directly. Your modifications will be lost.
# Run Redshift py36 tests
docker-compose run test tox -e integration-redshift-py36 -- -x
```
Follow the steps to [install `changie`](https://changie.dev/guide/installation/) for your system.
See the `Makefile` contents for more some other examples of ways to run `tox`.
Once changie is installed and your PR is created, simply run `changie new` and changie will walk you through the process of creating a changelog entry. Commit the file that's created and your changelog entry is complete!
### Submitting a Pull Request
You don't need to worry about which `dbt-core` version your change will go into. Just create the changelog entry with `changie`, and open your PR against the `main` branch. All merged changes will be included in the next minor version of `dbt-core`. The Core maintainers _may_ choose to "backport" specific changes in order to patch older minor versions. In that case, a maintainer will take care of that backport after merging your PR, before releasing the new version of `dbt-core`.
Fishtown Analytics provides a sandboxed Redshift, Snowflake, and BigQuery database for use in a CI environment.
## Submitting a Pull Request
When pull requests are submitted to the `fishtown-analytics/dbt` repo, GitHub will trigger automated tests in CircleCI and Azure Pipelines. If the PR submitter is a member of the `fishtown-analytics` GitHub organization, then the credentials for these databases will be automatically supplied as environment variables in the CI test suite.
A `dbt-core` maintainer will review your PR. They may suggest code revision for style or clarity, or request that you add unit or integration test(s). These are good things! We believe that, with a little bit of help, anyone can contribute high-quality code.
**If the PR submitter is not a member of the `fishtown-analytics` organization, then these environment variables will not be automatically supplied in the CI environment**. Once a core maintainer has taken a look at the Pull Request, they will kick off the test suite with the required credentials.
Automated tests run via GitHub Actions. If you're a first-time contributor, all tests (including code checks and unit tests) will require a maintainer to approve. Changes in the `dbt-core` repository trigger integration tests against Postgres. dbt Labs also provides CI environments in which to test changes to other adapters, triggered by PRs in those adapters' repositories, as well as periodic maintenance checks of each adapter in concert with the latest `dbt-core` code changes.
Once your tests are passing and your PR has been reviewed, a dbt maintainer will merge your changes into the active development branch! And that's it! Happy developing :tada:
Once all tests are passing and your PR has been approved, a `dbt-core` maintainer will merge your changes into the active development branch. And that's it! Happy developing :tada:
**[dbt](https://www.getdbt.com/)** (data build tool) enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.
**[dbt](https://www.getdbt.com/)** enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.
dbt is the T in ELT. Organize, cleanse, denormalize, filter, rename, and pre-aggregate the raw data in your warehouse so that it's ready for analysis.
dbt can be used to [aggregate pageviews into sessions](https://github.com/fishtown-analytics/snowplow), calculate [ad spend ROI](https://github.com/fishtown-analytics/facebook-ads), or report on [email campaign performance](https://github.com/fishtown-analytics/mailchimp).
@@ -30,28 +17,22 @@ Analysts using dbt can transform their data by simply writing select statements,
These select statements, or "models", form a dbt project. Models frequently build on top of one another – dbt makes it easy to [manage relationships](https://docs.getdbt.com/docs/ref) between models, and [visualize these relationships](https://docs.getdbt.com/docs/documentation), as well as assure the quality of your transformations through [testing](https://docs.getdbt.com/docs/testing).
- Read the [introduction](https://docs.getdbt.com/docs/introduction/) and [viewpoint](https://docs.getdbt.com/docs/about/viewpoint/)
## Find out more
## Join the dbt Community
- Check out the [Introduction to dbt](https://docs.getdbt.com/docs/introduction/).
- Read the [dbt Viewpoint](https://docs.getdbt.com/docs/about/viewpoint/).
## Join thousands of analysts in the dbt community
- Join the [chat](http://community.getdbt.com/) on Slack.
- Find community posts on [dbt Discourse](https://discourse.getdbt.com).
-Be part of the conversation in the [dbt Community Slack](http://community.getdbt.com/)
- Read more on the [dbt Community Discourse](https://discourse.getdbt.com)
## Reporting bugs and contributing code
- Want to report a bug or request a feature? Let us know on [Slack](http://slack.getdbt.com/), or open [an issue](https://github.com/fishtown-analytics/dbt/issues/new).
- Want to help us build dbt? Check out the [Contributing Getting Started Guide](/CONTRIBUTING.md)
- Want to report a bug or request a feature? Let us know on [Slack](http://community.getdbt.com/), or open [an issue](https://github.com/dbt-labs/dbt-core/issues/new)
- Want to help us build dbt? Check out the [Contributing Guide](https://github.com/dbt-labs/dbt-core/blob/HEAD/CONTRIBUTING.md)
- **Trunks** track the latest release of a minor version of dbt. Historically, we used the `master` branch as the trunk. Each minor version release has a corresponding trunk. For example, the `0.11.x` series of releases has a branch called `0.11.latest`. This allows us to release new patch versions under `0.11` without necessarily needing to pull them into the latest version of dbt.
- **Release Branches** track a specific, not yet complete release of dbt. These releases are codenamed since we don't always know what their semantic version will be. Example: `dev/lucretia-mott` became `0.11.1`.
- **Feature Branches** track individual features and fixes. On completion they should be merged into a release branch.
#### Git & PyPI
1. Update CHANGELOG.md with the most recent changes
2. If this is a release candidate, you want to create it off of your release branch. If it's an actual release, you must first merge to a master branch. Open a Pull Request in Github to merge it into the appropriate trunk (`X.X.latest`)
3. Bump the version using `bumpversion`:
- Dry run first by running `bumpversion --new-version <desired-version> <part>` and checking the diff. If it looks correct, clean up the chanages and move on:
- Minor releases: `bumpversion --commit --no-tag --new-version 0.11.0 minor`
- Major releases: `bumpversion --commit --no-tag --new-version 1.0.0 major`
4. (If this is a not a release candidate) Merge to `x.x.latest` and (optionally) `master`.
5. Update the default branch to the next dev release branch.
6. Build source distributions for all packages by running `./scripts/build-sdists.sh`. Note that this will clean out your `dist/` folder, so if you have important stuff in there, don't run it!!!
7. Deploy to pypi
-`twine upload dist/*`
8. Deploy to homebrew (see below)
9. Deploy to conda-forge (see below)
10. Git release notes (points to changelog)
11. Post to slack (point to changelog)
After releasing a new version, it's important to merge the changes back into the other outstanding release branches. This avoids merge conflicts moving forward.
In some cases, where the branches have diverged wildly, it's ok to skip this step. But this means that the changes you just released won't be included in future releases.
2. For ALL releases (prereleases and version releases), copy the relevant formula. To copy from the latest version release of dbt, do:
```bash
cp Formula/dbt.rb Formula/dbt@{NEW-VERSION}.rb
```
To copy from a different version, simply copy the corresponding file.
3. Open the file, and edit the following:
- the name of the ruby class: this is important, homebrew won't function properly if the class name is wrong. Check historical versions to figure out the right name.
- under the `bottle` section, remove all of the hashes (lines starting with `sha256`)
4. Create a **Python 3.7** virtualenv, activate it, and then install two packages: `homebrew-pypi-poet`, and the version of dbt you are preparing. I use:
```
pyenv virtualenv 3.7.0 homebrew-dbt-{VERSION}
pyenv activate homebrew-dbt-{VERSION}
pip install dbt=={VERSION} homebrew-pypi-poet
```
homebrew-pypi-poet is a program that generates a valid homebrew formula for an installed pip package. You want to use it to generate a diff against the existing formula. Then you want to apply the diff for the dependency packages only -- e.g. it will tell you that `google-api-core` has been updated and that you need to use the latest version.
5. reinstall, test, and audit dbt. if the test or audit fails, fix the formula with step 1.
```bash
brew uninstall --force Formula/{YOUR-FILE}.rb
brew install Formula/{YOUR-FILE}.rb
brew test dbt
brew audit --strict dbt
```
6. Ask Connor to bottle the change (only his laptop can do it!)
#### Conda Forge Release Process
1. Clone the fork of `conda-forge/dbt-feedstock` [here](https://github.com/fishtown-analytics/dbt-feedstock)
**[dbt](https://www.getdbt.com/)** enables data analysts and engineers to transform their data using the same practices that software engineers use to build applications.
Analysts using dbt can transform their data by simply writing select statements, while dbt handles turning these statements into tables and views in a data warehouse.
These select statements, or "models", form a dbt project. Models frequently build on top of one another – dbt makes it easy to [manage relationships](https://docs.getdbt.com/docs/ref) between models, and [visualize these relationships](https://docs.getdbt.com/docs/documentation), as well as assure the quality of your transformations through [testing](https://docs.getdbt.com/docs/testing).
- Read the [introduction](https://docs.getdbt.com/docs/introduction/) and [viewpoint](https://docs.getdbt.com/docs/about/viewpoint/)
## Join the dbt Community
- Be part of the conversation in the [dbt Community Slack](http://community.getdbt.com/)
- Read more on the [dbt Community Discourse](https://discourse.getdbt.com)
## Reporting bugs and contributing code
- Want to report a bug or request a feature? Let us know on [Slack](http://community.getdbt.com/), or open [an issue](https://github.com/dbt-labs/dbt-core/issues/new)
- Want to help us build dbt? Check out the [Contributing Guide](https://github.com/dbt-labs/dbt-core/blob/HEAD/CONTRIBUTING.md)
## Code of Conduct
Everyone interacting in the dbt project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [dbt Code of Conduct](https://community.getdbt.com/code-of-conduct).
# This will add to the package’s __path__ all subdirectories of directories on sys.path named after the package which effectively combines both modules into a single namespace (dbt.adapters)
# The matching statement is in plugins/postgres/dbt/__init__.py
The Adapters module is responsible for defining database connection methods, caching information from databases, how relations are defined, and the two major connection types we have - base and sql.
# Directories
## `base`
Defines the base implementation Adapters can use to build out full functionality.
## `sql`
Defines a sql implementation for adapters that initially inherits the above base implementation and comes with some premade methods and macros that can be overwritten as needed per adapter. (most common type of adapter.)
# Files
## `cache.py`
Cached information from the database.
## `factory.py`
Defines how we generate adapter objects
## `protocol.py`
Defines various interfaces for various adapter objects. Helps mypy correctly resolve methods.
## `reference_keys.py`
Configures naming scheme for cache elements to be universal.
# This will add to the package’s __path__ all subdirectories of directories on sys.path named after the package which effectively combines both modules into a single namespace (dbt.adapters)
# The matching statement is in plugins/postgres/dbt/adapters/__init__.py
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.