Compare commits

...

4 Commits

Author SHA1 Message Date
Github Build Bot
8f506a1b3d Bumping version to 1.8.0rc2 and generate changelog 2024-05-08 00:36:54 +00:00
Quigley Malcolm
40343274d9 Enable serialization context (#10094) (#10104)
* Update __post_serialize__ signatures

* Temporarily linke dbt-common and dbt-adapters branches

* Changie

* Move fields not in artifacts to resource __post_serialize__ methods

* remove defer_relation in snapshots

* Remove references to branch changes

Co-authored-by: Gerda Shank <gerda@dbtlabs.com>
2024-05-07 17:27:40 -07:00
FishtownBuildBot
062a7788bd [Automated] Merged prep-release/1.8.0rc1_8928720002 into target 1.8.latest during release process 2024-05-02 12:53:44 -06:00
Github Build Bot
cf600a62fd Bumping version to 1.8.0rc1 and generate changelog 2024-05-02 18:33:43 +00:00
42 changed files with 162 additions and 42 deletions

View File

@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.8.0b3
current_version = 1.8.0rc2
parse = (?P<major>[\d]+) # major version number
\.(?P<minor>[\d]+) # minor version number
\.(?P<patch>[\d]+) # patch version number

43
.changes/1.8.0-rc1.md Normal file
View File

@@ -0,0 +1,43 @@
## dbt-core 1.8.0-rc1 - May 02, 2024
### Breaking Changes
- Update the default behaviour of require_explicit_package_overrides_for_builtin_materializations to True. ([#10062](https://github.com/dbt-labs/dbt-core/issues/10062))
### Features
- Package selector syntax for the current package ([#6891](https://github.com/dbt-labs/dbt-core/issues/6891))
- Add require_explicit_package_overrides_for_builtin_materializations to dbt_project.yml flags, which can be used to opt-out of overriding built-in materializations from packages ([#10007](https://github.com/dbt-labs/dbt-core/issues/10007))
- add --empty flag to dbt build command ([#10026](https://github.com/dbt-labs/dbt-core/issues/10026))
- Ability to `silence` warnings via `warn_error_options` ([#9644](https://github.com/dbt-labs/dbt-core/issues/9644))
- Allow aliases `error` for `include` and `warn` for `exclude` in `warn_error_options` ([#9644](https://github.com/dbt-labs/dbt-core/issues/9644))
### Fixes
- Add NodeRelation to SavedQuery Export ([#9534](https://github.com/dbt-labs/dbt-core/issues/9534))
- Use consistent secret scrubbing with the log function. ([#9987](https://github.com/dbt-labs/dbt-core/issues/9987))
- Validate against empty strings in package definitions ([#9985](https://github.com/dbt-labs/dbt-core/issues/9985))
- Fix default value for indirect selection in selector cannot overwritten by CLI flag and env var ([#9976](https://github.com/dbt-labs/dbt-core/issues/9976), [#7673](https://github.com/dbt-labs/dbt-core/issues/7673))
- Simplify error message if test severity isn't 'warn' or 'error' ([#9715](https://github.com/dbt-labs/dbt-core/issues/9715))
- Support overriding source level loaded_at_field with a null table level definition ([#9320](https://github.com/dbt-labs/dbt-core/issues/9320))
### Docs
- Enable display of unit tests ([dbt-docs/#501](https://github.com/dbt-labs/dbt-docs/issues/501))
- Unit tests not rendering ([dbt-docs/#506](https://github.com/dbt-labs/dbt-docs/issues/506))
### Under the Hood
- Split up deferral across parsing (adding 'defer_relation' from state manifest) and runtime ref resolution" ([#9199](https://github.com/dbt-labs/dbt-core/issues/9199))
- Raise deprecation warning if installed package overrides built-in materialization ([#9971](https://github.com/dbt-labs/dbt-core/issues/9971))
- Use the SECRET_ENV_PREFIX from dbt_common instead of duplicating it in dbt-core ([#10018](https://github.com/dbt-labs/dbt-core/issues/10018))
- Enable use of record mode via environment variable ([#10045](https://github.com/dbt-labs/dbt-core/issues/10045))
- Consistent naming + deprecation warnings for "legacy behavior" flags ([#10062](https://github.com/dbt-labs/dbt-core/issues/10062))
### Dependencies
- Update the agate pin to "agate>=1.7.0,<1.10" ([#9934](https://github.com/dbt-labs/dbt-core/issues/9934))
### Contributors
- [@barton996](https://github.com/barton996) ([#6891](https://github.com/dbt-labs/dbt-core/issues/6891))
- [@mjkanji](https://github.com/mjkanji) ([#9934](https://github.com/dbt-labs/dbt-core/issues/9934))

5
.changes/1.8.0-rc2.md Normal file
View File

@@ -0,0 +1,5 @@
## dbt-core 1.8.0-rc2 - May 08, 2024
### Under the Hood
- Enable use of context in serialization ([#10093](https://github.com/dbt-labs/dbt-core/issues/10093))

View File

@@ -0,0 +1,6 @@
kind: Under the Hood
body: Enable use of context in serialization
time: 2024-05-06T14:55:11.1812-04:00
custom:
Author: gshank
Issue: "10093"

View File

@@ -5,6 +5,58 @@
- "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)
## dbt-core 1.8.0-rc2 - May 08, 2024
### Under the Hood
- Enable use of context in serialization ([#10093](https://github.com/dbt-labs/dbt-core/issues/10093))
## dbt-core 1.8.0-rc1 - May 02, 2024
### Breaking Changes
- Update the default behaviour of require_explicit_package_overrides_for_builtin_materializations to True. ([#10062](https://github.com/dbt-labs/dbt-core/issues/10062))
### Features
- Package selector syntax for the current package ([#6891](https://github.com/dbt-labs/dbt-core/issues/6891))
- Add require_explicit_package_overrides_for_builtin_materializations to dbt_project.yml flags, which can be used to opt-out of overriding built-in materializations from packages ([#10007](https://github.com/dbt-labs/dbt-core/issues/10007))
- add --empty flag to dbt build command ([#10026](https://github.com/dbt-labs/dbt-core/issues/10026))
- Ability to `silence` warnings via `warn_error_options` ([#9644](https://github.com/dbt-labs/dbt-core/issues/9644))
- Allow aliases `error` for `include` and `warn` for `exclude` in `warn_error_options` ([#9644](https://github.com/dbt-labs/dbt-core/issues/9644))
### Fixes
- Add NodeRelation to SavedQuery Export ([#9534](https://github.com/dbt-labs/dbt-core/issues/9534))
- Use consistent secret scrubbing with the log function. ([#9987](https://github.com/dbt-labs/dbt-core/issues/9987))
- Validate against empty strings in package definitions ([#9985](https://github.com/dbt-labs/dbt-core/issues/9985))
- Fix default value for indirect selection in selector cannot overwritten by CLI flag and env var ([#9976](https://github.com/dbt-labs/dbt-core/issues/9976), [#7673](https://github.com/dbt-labs/dbt-core/issues/7673))
- Simplify error message if test severity isn't 'warn' or 'error' ([#9715](https://github.com/dbt-labs/dbt-core/issues/9715))
- Support overriding source level loaded_at_field with a null table level definition ([#9320](https://github.com/dbt-labs/dbt-core/issues/9320))
### Docs
- Enable display of unit tests ([dbt-docs/#501](https://github.com/dbt-labs/dbt-docs/issues/501))
- Unit tests not rendering ([dbt-docs/#506](https://github.com/dbt-labs/dbt-docs/issues/506))
### Under the Hood
- Split up deferral across parsing (adding 'defer_relation' from state manifest) and runtime ref resolution" ([#9199](https://github.com/dbt-labs/dbt-core/issues/9199))
- Raise deprecation warning if installed package overrides built-in materialization ([#9971](https://github.com/dbt-labs/dbt-core/issues/9971))
- Use the SECRET_ENV_PREFIX from dbt_common instead of duplicating it in dbt-core ([#10018](https://github.com/dbt-labs/dbt-core/issues/10018))
- Enable use of record mode via environment variable ([#10045](https://github.com/dbt-labs/dbt-core/issues/10045))
- Consistent naming + deprecation warnings for "legacy behavior" flags ([#10062](https://github.com/dbt-labs/dbt-core/issues/10062))
### Dependencies
- Update the agate pin to "agate>=1.7.0,<1.10" ([#9934](https://github.com/dbt-labs/dbt-core/issues/9934))
### Contributors
- [@barton996](https://github.com/barton996) ([#6891](https://github.com/dbt-labs/dbt-core/issues/6891))
- [@mjkanji](https://github.com/mjkanji) ([#9934](https://github.com/dbt-labs/dbt-core/issues/9934))
## dbt-core 1.8.0-b3 - April 18, 2024
### Features
@@ -54,7 +106,6 @@
- [@niteshy](https://github.com/niteshy) ([#9830](https://github.com/dbt-labs/dbt-core/issues/9830))
- [@rzjfr](https://github.com/rzjfr) ([#9373](https://github.com/dbt-labs/dbt-core/issues/9373))
## dbt-core 1.8.0-b2 - April 03, 2024
### Features

View File

@@ -196,6 +196,12 @@ class ParsedResource(ParsedResourceMandatory):
relation_name: Optional[str] = None
raw_code: str = ""
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if context and context.get("artifact") and "config_call_dict" in dct:
del dct["config_call_dict"]
return dct
@dataclass
class CompiledResource(ParsedResource):
@@ -215,8 +221,8 @@ class CompiledResource(ParsedResource):
_pre_injected_sql: Optional[str] = None
contract: Contract = field(default_factory=Contract)
def __post_serialize__(self, dct):
dct = super().__post_serialize__(dct)
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if "_pre_injected_sql" in dct:
del dct["_pre_injected_sql"]
# Remove compiled attributes

View File

@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import Literal, Optional, List
from typing import Dict, Literal, Optional, List
from datetime import datetime
from dbt_common.contracts.config.base import MergeBehavior
from dbt_common.contracts.constraints import ModelLevelConstraint
@@ -26,3 +26,9 @@ class Model(CompiledResource):
latest_version: Optional[NodeVersion] = None
deprecation_date: Optional[datetime] = None
defer_relation: Optional[DeferRelation] = None
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if context and context.get("artifact") and "defer_relation" in dct:
del dct["defer_relation"]
return dct

View File

@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
from typing import Optional, Literal
from typing import Dict, Optional, Literal
from dbt_common.dataclass_schema import ValidationError
from dbt.artifacts.resources.types import NodeType
from dbt.artifacts.resources.v1.components import MacroDependsOn, DeferRelation, ParsedResource
@@ -28,3 +28,9 @@ class Seed(ParsedResource): # No SQLDefaults!
root_path: Optional[str] = None
depends_on: MacroDependsOn = field(default_factory=MacroDependsOn)
defer_relation: Optional[DeferRelation] = None
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if context and context.get("artifact") and "defer_relation" in dct:
del dct["defer_relation"]
return dct

View File

@@ -1,4 +1,4 @@
from typing import Union, List, Optional, Literal
from typing import Dict, Union, List, Optional, Literal
from dataclasses import dataclass
from dbt_common.dataclass_schema import ValidationError
from dbt.artifacts.resources.types import NodeType
@@ -64,3 +64,9 @@ class Snapshot(CompiledResource):
resource_type: Literal[NodeType.Snapshot]
config: SnapshotConfig
defer_relation: Optional[DeferRelation] = None
def __post_serialize__(self, dct, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if context and context.get("artifact") and "defer_relation" in dct:
del dct["defer_relation"]
return dct

View File

@@ -34,7 +34,7 @@ class SchemaVersion:
class Writable:
def write(self, path: str):
write_json(path, self.to_dict(omit_none=False)) # type: ignore
write_json(path, self.to_dict(omit_none=False, context={"artifact": True})) # type: ignore
class Readable:
@@ -60,8 +60,8 @@ class BaseArtifactMetadata(dbtClassMixin):
invocation_id: Optional[str] = dataclasses.field(default_factory=get_invocation_id)
env: Dict[str, str] = dataclasses.field(default_factory=get_metadata_vars)
def __post_serialize__(self, dct):
dct = super().__post_serialize__(dct)
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if dct["generated_at"] and dct["generated_at"].endswith("+00:00"):
dct["generated_at"] = dct["generated_at"].replace("+00:00", "") + "Z"
return dct

View File

@@ -77,8 +77,8 @@ class CatalogResults(dbtClassMixin):
errors: Optional[List[str]] = None
_compile_results: Optional[Any] = None
def __post_serialize__(self, dct):
dct = super().__post_serialize__(dct)
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if "_compile_results" in dct:
del dct["_compile_results"]
return dct

View File

@@ -181,11 +181,3 @@ class WritableManifest(ArtifactMixin):
if manifest_schema_version < cls.dbt_schema_version.version:
data = upgrade_manifest_json(data, manifest_schema_version)
return cls.from_dict(data)
def __post_serialize__(self, dct):
for unique_id, node in dct["nodes"].items():
if "config_call_dict" in node:
del node["config_call_dict"]
if "defer_relation" in node:
del node["defer_relation"]
return dct

View File

@@ -139,8 +139,8 @@ class BaseSourceFile(dbtClassMixin, SerializableType):
sf = SourceFile.from_dict(dct)
return sf
def __post_serialize__(self, dct):
dct = super().__post_serialize__(dct)
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
# remove empty lists to save space
dct_keys = list(dct.keys())
for key in dct_keys:
@@ -226,8 +226,8 @@ class SchemaSourceFile(BaseSourceFile):
def source_patches(self):
return self.sop
def __post_serialize__(self, dct):
dct = super().__post_serialize__(dct)
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
# Remove partial parsing specific data
for key in ("pp_test_index", "pp_dict"):
if key in dct:

View File

@@ -2,7 +2,6 @@ import enum
from collections import defaultdict
from dataclasses import dataclass, field, replace
from itertools import chain
from mashumaro.mixins.msgpack import DataClassMessagePackMixin
from multiprocessing.synchronize import Lock
from typing import (
DefaultDict,
@@ -803,7 +802,7 @@ ResourceClassT = TypeVar("ResourceClassT", bound="BaseResource")
@dataclass
class Manifest(MacroMethods, DataClassMessagePackMixin, dbtClassMixin):
class Manifest(MacroMethods, dbtClassMixin):
"""The manifest for the full graph, after parsing and during compilation."""
# These attributes are both positional and by keyword. If an attribute
@@ -870,7 +869,7 @@ class Manifest(MacroMethods, DataClassMessagePackMixin, dbtClassMixin):
metadata={"serialize": lambda x: None, "deserialize": lambda x: None},
)
def __pre_serialize__(self):
def __pre_serialize__(self, context: Optional[Dict] = None):
# serialization won't work with anything except an empty source_patches because
# tuple keys are not supported, so ensure it's empty
self.source_patches = {}

View File

@@ -262,8 +262,8 @@ class ParsedNode(ParsedResource, NodeInfoMixin, ParsedNodeMandatory, Serializabl
def _serialize(self):
return self.to_dict()
def __post_serialize__(self, dct):
dct = super().__post_serialize__(dct)
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if "_event_status" in dct:
del dct["_event_status"]
return dct

View File

@@ -276,8 +276,8 @@ class UnparsedSourceTableDefinition(HasColumnTests, HasColumnAndTestProps):
external: Optional[ExternalTable] = None
tags: List[str] = field(default_factory=list)
def __post_serialize__(self, dct):
dct = super().__post_serialize__(dct)
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if "freshness" not in dct and self.freshness is None:
dct["freshness"] = None
return dct
@@ -314,8 +314,8 @@ class UnparsedSourceDefinition(dbtClassMixin):
def yaml_key(self) -> "str":
return "sources"
def __post_serialize__(self, dct):
dct = super().__post_serialize__(dct)
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
dct = super().__post_serialize__(dct, context)
if "freshness" not in dct and self.freshness is None:
dct["freshness"] = None
return dct

View File

@@ -233,7 +233,7 @@ class ManifestLoaderInfo(dbtClassMixin, Writable):
projects: List[ProjectLoaderInfo] = field(default_factory=list)
_project_index: Dict[str, ProjectLoaderInfo] = field(default_factory=dict)
def __post_serialize__(self, dct):
def __post_serialize__(self, dct: Dict, context: Optional[Dict] = None):
del dct["_project_index"]
return dct

View File

@@ -229,5 +229,5 @@ def _get_adapter_plugin_names() -> Iterator[str]:
yield plugin_name
__version__ = "1.8.0b3"
__version__ = "1.8.0rc2"
installed = get_installed_version()

View File

@@ -25,7 +25,7 @@ with open(os.path.join(this_directory, "README.md")) as f:
package_name = "dbt-core"
package_version = "1.8.0b3"
package_version = "1.8.0rc2"
description = """With dbt, data analysts and engineers can build analytics \
the way engineers build applications."""

View File

@@ -16,7 +16,7 @@ def build_json_schema(
class JSONSchemaDefinitions(DataClassJSONMixin):
definitions: Dict[str, JSONSchema]
def __post_serialize__(self, d: Dict[Any, Any]) -> List[Dict[str, Any]]: ... # type: ignore
def __post_serialize__(self, d: Dict[Any, Any], context: Optional[Dict]) -> List[Dict[str, Any]]: ... # type: ignore
def __init__(self, definitions) -> None: ...
class JSONSchemaBuilder:

View File

@@ -106,8 +106,8 @@ class JSONSchema(DataClassJSONMixin):
serialize_by_alias: bool
aliases: Incomplete
serialization_strategy: Incomplete
def __pre_serialize__(self) -> JSONSchema: ...
def __post_serialize__(self, d: Dict[Any, Any]) -> Dict[Any, Any]: ...
def __pre_serialize__(self, context: Optional[Dict]) -> JSONSchema: ...
def __post_serialize__(self, d: Dict[Any, Any], context: Optional[Dict]) -> Dict[Any, Any]: ...
def __init__(
self,
schema,

View File

@@ -1,4 +1,4 @@
from typing import Any, Dict, Mapping, Type, TypeVar
from typing import Any, Dict, Mapping, Type, TypeVar, Optional
T = TypeVar("T", bound="DataClassDictMixin")
@@ -11,5 +11,5 @@ class DataClassDictMixin:
def __pre_deserialize__(cls: Type[T], d: Dict[Any, Any]) -> Dict[Any, Any]: ...
@classmethod
def __post_deserialize__(cls: Type[T], obj: T) -> T: ...
def __pre_serialize__(self: T) -> T: ...
def __post_serialize__(self, d: Dict[Any, Any]) -> Dict[Any, Any]: ...
def __pre_serialize__(self: T, context: Optional[Dict]) -> T: ...
def __post_serialize__(self, d: Dict[Any, Any], context: Optional[Dict]) -> Dict[Any, Any]: ...