Skip to content

Commit e920053

Browse files
Initial slate of deprecations for 1.10 (#11544)
* Begin basic jsonschema validations of dbt_project.yml (#11505) * Add jsonschema for validation project file * Add utility for helping to load jsonschema resources Currently things are a bit hard coded. We should probably alter this to be a bit more flexible. * Begin validating the the `dbt_project.yml` via jsonschema * Begin emitting deprecation warnings for generic jsonschema violations in dbt_project.yml * Move from `DbtInternalError` to `DbtRuntimeError` to avoid circular imports * Add tests for basic jsonschema validation of `dbt_project.yml` * Add changie doc * Add seralization test for new deprecation events * Alter the project jsonschema to not require things that are optional * Add datafiles to package egg * Update inclusion of project jsonschema in setup.py to get files correctly Using the glob spec returns a list of found files. Our previous spec was raising the error `error: can't copy 'dbt/resources/input_schemas/project/*.json': doesn't exist or not a regular file` * Try another approach of adding jsonschema to egg * Add input_schemas dir to MANIFEST.in spec * Drop jsonschema inclusion spec from setup.py * Begin using importlib.resources.files for loading project jsonschema This doesn't currently work with editable installs :'( * Use relative paths for loading jsonchemas instead of importlib Using "importlib" is the blessed way to do this sort of thing. However, that is failing for us on editable installs. This commit switches us to using relative paths. Technically doing this has edge cases, however this is also what we do for the `start_project` used in `dbt init`. So we're going to do the same, for now. We should revisit this soon. * Drop requirment of `__additional_properties__` specified by project jsonschema * Drop requirement for `pre-hook` and `post-hook` specified by project jsonschema * Reset `active_deprecations` global at the end of tests using `project` fixture * Begin validation the jsonschema of YAML resource files (#11516) * Add jsonschema for resources * Begin jsonschema validating YAML resource files in dbt projects * Drop `tests` and `data_tests` as required properties of `Columns` and `Models` for resources jsonschema * Drop `__additional_properties__` as required for `_Metrics` in resources jsonschema * Drop `post_hook` and `pre_hook` requirement for `__SnapshotsConfig` in resources jsonschema * Update `_error_path_to_string` to handle empty paths * Create + use custom Draft7Validator to ignore datetime and date classes * Break `TestRetry` functional test class into multiple test classes There was some overflow global state from one test to another which was causing some of the tests to break. * Refactor duplicate instances of `jsonschema_validate` to single definition * Begin testing jsonschema validation of resource YAMLs * Add changie doc * Add Deprecation Warnings for Unexpected Jinja Blocks (#11514) * Add deprecation warnings on unexpected jinja blocks. * Add changelog entry. * Add test event. * Regen proto types. * Fix event test. * Add `UnexpectedJinjaBlockDeprecationSummary` and add file context to `UnexpectedJinjaBlockDeprecation` (#11517) * Add summary event for UnexpectedJinjaBlockDeprecation * Begin including file information in UnexpectedJinjaBlockDeprecation event * Add UnexpectedJinjaBlockDeprecationSummary to test_events.py * Deprecate Custom Top-Level Keys (#11518) * Add specific deprecation for custom top level keys. * Add changelog entry * Add test events * Add Check for Duplicate YAML Keys (#11510) * Add functionality to check for duplicate yaml keys, working around PyYAML limitation. * Fix up some ancient typing issues. * Ignore typing issue, for now. * Correct unit tests of `checked_load` * Add event and deprecation types for duplicate yaml keys * Begin validating `dbt_project.yml` for duplicate key violations * Begin checking for duplicate key violations in schema files * Add test to check duplicate keys are checked in schema files * Refactor checked_yaml failure handling to reduce duplicate code * Move `checked_load` utilities to separate file to avoid circular imports * Handle yaml `start_mark` correctly for top level key errors * Update changelog * Fix test. --------- Co-authored-by: Quigley Malcolm <[email protected]> * Fix issue with YAML anchors in new CheckedLoader class. * Deprecate having custom keys in config blocks (#11522) * Add deprecation event for custom keys found in configs * Begin checking schema files for custom keys found in configs * Test new CustomConfigInConfigDeprecation event * Add changie doc * Add custom config key deprecation events to event serialization test * Provide message to ValidationError in `SelectorConfig.from_path` This typing error is unrelated to the changes in this PR. However, it was failing CI, so I figured it'd be simple to just fix it. * Add some extra guards around the ValidationFailure `path` and `instance` * [TIDY-FRIST] Use new `deprecation_tag` (#11524) * Tidy First: Update deprecation events to use the new `deprecation_tag` Note did this for a majority of deprecations, but not _all_ deprecations. That is because not all deprecations were following the pattern. As some people do string parsing of our logs with regex, altering the deprecations that weren't doing what `deprecation_tag` does to use `deprecation_tag` would be a _breaking change_ for those events, thus we did not alter those events * Bump minimum dbt-common to `1.22.0` * Fix tests * Begin emitting deprecation events for custom properties found in objects (#11526) * Fix CustomKeyInConfigDeprecationSummary * Add deprecation type for custom properties in YAML objects * Begin emitting deprecation events for custom properties found in objects * Add changie doc * Add `loaded_at_query` property to `_Sources` definition in jsonschema This was breaking the test tests/unit/parser/test_parser.py::SchemaParserSourceTest::test_parse_source_custom_freshness_at_source * Move validating jsonschema of schema files earlier in the process Previously we were validating the jsonschema of schema files in `SchemaParser.parse_file`. However, the file is originally loaded in `yaml_from_file` (which happens before `SchemaParser.parse_file`), and `yaml_from_file` _modifies_ the loaded dictionary to add some additional properties. These additional properties violate the jsonschema unfortunately, and thus we needed to start validating the schema against the jsonschema before any such modifications. * Skip parser tests for `model.freshness` Model freshness never got fully implemented, won't be implemented nor documented for 1.10. As such we're gonna consider the `model.freshness` property an "unknown additional property". This is actually good as some people have "accidentally" defined "freshness" on their models (likely due to copy/paste of a source), and that property isn't doing anything. * One single DeprecationsSummary event to rule them all (#11540) * Begin emitting singular deprecations summary, instead of summary per deprecation type * Remove concept of deprecation specific summary events in deprecations module * Drop deprecation summary events that have been added to `feature-branch--11335-deprecations` but not `main` These are save to drop with no notice because they only ever existed on a feature branch, never main. * Correct code numbers for new events on feature-branch that haven't made it to main yet * Kill `PackageRedirectDeprecationSummary` event, and retire its event code * add changie doc * Update jsonschemas to versions 0.0.110 (#11541) * Update jsonschems to 0.0.110 * Don't allow additional properties in configs * Don't allow additional top level properties on objects * Allow for 'loaded_at_query' on Sources and Tables * Don't allow additional top level properties in schema files --------- Co-authored-by: Peter Webb <[email protected]>
1 parent 511ff8e commit e920053

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+10735
-745
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Basic jsonschema validation of `dbt_project.yml`
3+
time: 2025-04-14T17:12:09.351572-07:00
4+
custom:
5+
Author: QMalcolm
6+
Issue: "11503"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Freatures
2+
body: Begin checking YAML files for duplicate keys
3+
time: 2025-04-15T13:37:51.878256-04:00
4+
custom:
5+
Author: peterallenwebb QMalcolm
6+
Issue: "11296"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Add deprecation warnings for unexpected blocks in jinja.
3+
time: 2025-04-16T14:44:27.136199-04:00
4+
custom:
5+
Author: peterallenwebb
6+
Issue: "11393"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Begin validating the jsonschema of resource YAML files
3+
time: 2025-04-16T15:17:11.760509-07:00
4+
custom:
5+
Author: QMalcolm
6+
Issue: "11504"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Add deprecation warning for custom top level keys in YAML files.
3+
time: 2025-04-17T00:13:47.744191-04:00
4+
custom:
5+
Author: peterallenwebb
6+
Issue: "11338"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Begin emitting deprecationw warnings for custom keys in config blocks
3+
time: 2025-04-17T11:49:15.056242-07:00
4+
custom:
5+
Author: QMalcolm
6+
Issue: "11337"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Begin emitting deprecation events for custom properties found in objects
3+
time: 2025-04-18T10:42:10.048839-07:00
4+
custom:
5+
Author: QMalcolm
6+
Issue: "11336"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Create a singular deprecations summary event
3+
time: 2025-04-24T15:33:27.252763-05:00
4+
custom:
5+
Author: QMalcolm
6+
Issue: "11536"

core/MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
recursive-include dbt/include *.py *.sql *.yml *.html *.md .gitkeep .gitignore
1+
recursive-include dbt/include *.py *.sql *.yml *.html *.md .gitkeep .gitignore *.json
22
include dbt/py.typed
33
recursive-include dbt/task/docs *.html

core/dbt/cli/requires.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from dbt.config.runtime import UnsetProfile, load_profile, load_project
1717
from dbt.context.providers import generate_runtime_macro_context
1818
from dbt.context.query_header import generate_query_header_context
19-
from dbt.deprecations import show_all_deprecation_summaries
19+
from dbt.deprecations import show_deprecations_summary
2020
from dbt.events.logging import setup_event_logger
2121
from dbt.events.types import (
2222
ArtifactUploadError,
@@ -181,7 +181,7 @@ def wrapper(*args, **kwargs):
181181
except Exception as e:
182182
fire_event(ArtifactUploadError(msg=str(e)))
183183

184-
show_all_deprecation_summaries()
184+
show_deprecations_summary()
185185

186186
if importlib.util.find_spec("resource") is not None:
187187
import resource
@@ -267,8 +267,10 @@ def wrapper(*args, **kwargs):
267267
raise DbtProjectError("profile required for project")
268268

269269
flags = ctx.obj["flags"]
270+
# TODO deprecations warnings fired from loading the project will lack
271+
# the project_id in the snowplow event.
270272
project = load_project(
271-
flags.PROJECT_DIR, flags.VERSION_CHECK, ctx.obj["profile"], flags.VARS
273+
flags.PROJECT_DIR, flags.VERSION_CHECK, ctx.obj["profile"], flags.VARS, validate=True
272274
)
273275
ctx.obj["project"] = project
274276

0 commit comments

Comments
 (0)