Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3867] Turn on partial parsing by default #3989

Merged
merged 1 commit into from
Oct 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Normalize global CLI arguments/flags ([#2990](https:/dbt-labs/dbt/issues/2990), [#3839](https:/dbt-labs/dbt/pull/3839))
- Turns on the static parser by default and adds the flag `--no-static-parser` to disable it. ([#3377](https:/dbt-labs/dbt/issues/3377), [#3939](https:/dbt-labs/dbt/pull/3939))
- Generic test FQNs have changed to include the relative path, resource, and column (if applicable) where they are defined. This makes it easier to configure them from the `tests` block in `dbt_project.yml` ([#3259](https:/dbt-labs/dbt/pull/3259), [#3880](https:/dbt-labs/dbt/pull/3880)
- Turn on partial parsing by default ([#3867](https:/dbt-labs/dbt/issues/3867), [#3989](https:/dbt-labs/dbt/issues/3989))

### Fixes
- Add generic tests defined on sources to the manifest once, not twice ([#3347](https:/dbt-labs/dbt/issues/3347), [#3880](https:/dbt-labs/dbt/pull/3880))
Expand Down
6 changes: 6 additions & 0 deletions core/dbt/contracts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ class BaseArtifactMetadata(dbtClassMixin):
)
env: Dict[str, str] = dataclasses.field(default_factory=get_metadata_env)

def __post_serialize__(self, dct):
dct = super().__post_serialize__(dct)
if dct['generated_at'] and dct['generated_at'].endswith('+00:00'):
dct['generated_at'] = dct['generated_at'].replace('+00:00', '') + "Z"
return dct


def schema_version(name: str, version: int):
def inner(cls: Type[VersionedSchema]):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"STATIC_PARSER": True,
"WARN_ERROR": False,
"WRITE_JSON": True,
"PARTIAL_PARSE": False,
"PARTIAL_PARSE": True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Some parts of the code want the Z ending, and some parts don't, apparently. I moved the kludging of 'generated_at' into a post serialization method in BaseArtifactMetadata.

"USE_COLORS": True,
"PROFILES_DIR": DEFAULT_PROFILES_DIR,
"DEBUG": False,
Expand Down
8 changes: 8 additions & 0 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dataclasses import dataclass
from dataclasses import field
from datetime import datetime
import os
import traceback
from typing import (
Expand Down Expand Up @@ -557,6 +558,13 @@ def read_manifest_for_partial_parse(self) -> Optional[Manifest]:
# different version of dbt
is_partial_parseable, reparse_reason = self.is_partial_parsable(manifest)
if is_partial_parseable:
# We don't want to have stale generated_at dates
manifest.metadata.generated_at = datetime.utcnow()
# or invocation_ids
if dbt.tracking.active_user:
manifest.metadata.invocation_id = dbt.tracking.active_user.invocation_id
else:
manifest.metadata.invocation_id = None
Comment on lines +561 to +567
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return manifest
except Exception as exc:
logger.debug(
Expand Down
4 changes: 2 additions & 2 deletions test/rpc/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ def test_rpc_run_vars_compiled(
test_kwargs={},
)
with querier_ctx as querier:
results = querier.async_wait_for_result(querier.cli_args('run --vars "{materialized_var: table}"'))
results = querier.async_wait_for_result(querier.cli_args('--no-partial-parse run --vars "{materialized_var: table}"'))
assert len(results['results']) == 1
assert results['results'][0]['node']['config']['materialized'] == 'table'
# make sure that `--vars` doesn't update global state - if it does,
# this run() will result in a view!
results = querier.async_wait_for_result(querier.cli_args('run'))
results = querier.async_wait_for_result(querier.cli_args('--no-partial-parse run'))
assert len(results['results']) == 1
assert results['results'][0]['node']['config']['materialized'] == 'view'

Expand Down