-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Bug] Partial parsing error at path ['raw_code']: None is not of type 'string' when modifying source if snapshot is snapping the source and snapshot is declared with yaml #11164
Comments
Hello, confirmed the problem here. Disabling partial parsing fixed the issue. |
I was also able to reproduce this using the following files. Note: I only reproduced this parsing error when changing the Reprex
select 1 as id, {{ dbt.current_timestamp() }} as updated_at
sources:
- name: raw
database: "{{ target.database }}"
schema: "{{ target.schema }}"
tables:
- name: customers
description: Some description.
# description: Try to trigger parsing error.
snapshots:
- name: source_snapshot
relation: source('raw', 'customers')
config:
strategy: timestamp
unique_key: id
updated_at: updated_at
Run these commands:
|
Hi, same here using fwiw duckdb. |
Same here but with a regular source yaml file (not snapshot related). It became uneditable with a path ['raw_code']: None is not of type 'string' parsing error every time it was edited. Issue only resolved with dbt parse --no-partial-parse. |
Same issue here as well. adding --no-partial-parse helps, othewise getting errors when building, generating docs or parsing. |
Same here after adding a snapshot on dbt-core 1.9 - |
I had a similar error while I was updating 'model' yaml to 'source' yaml - dbt clean + dbt deps then rerunning cleared the issue for me |
Same as @maxmorganfield. However, I received the error again when updating the description and column names of the source in the yml. |
Had a bit of a look into this. The issue seems to start from core/dbt/parser/base.py#L248: def _create_parsetime_node(...) -> FinalNode:
"""Create the node that will be passed in to the parser context for
"rendering". Some information may be partial, as it'll be updated by
config() and any ref()/source() calls discovered during rendering.
"""
if name is None:
name = block.name
if block.path.relative_path.endswith(".py"):
language = ModelLanguage.python
else:
# this is not ideal but we have a lot of tests to adjust if don't do it
language = ModelLanguage.sql
dct = {
...
---> "raw_code": block.contents,
...
}
dct.update(kwargs)
try:
---> return self.parse_from_dict(dct, validate=True)
except ValidationError as exc:
...
raise DictParseError(exc, node=node) For projects with a snapshot using the new snapshot format, The schema used for validation comes from core/dbt/artifacts/resources/v1/components.py#L219: @dataclass
class ParsedResource(ParsedResourceMandatory):
...
raw_code: str = ""
... Which is referenced via the Snapshot class in core/dbt/artifacts/resources/v1/snapshot.py#L82. The Snapshot code does set a value for
@dataclass
class FileBlock:
file: AnySourceFile
@property
def contents(self):
return self.file.contents I see a few possible solutions to this:
I've created #11362 to implement the first option above, also happy to do any of the others depending on what's considered suitable for the project. |
Is this a new bug in dbt-core?
Current Behavior
If we have a snapshot declared in the fancy new yaml way that is snapping a source - then partial parsing will error when the source is modified.
Expected Behavior
No error.
Steps To Reproduce
Project setup.
Do an initial parse:
Edit the description of our source:
Do a subsequent - i.e. partially parsed parse:
Workaround: Do a full parse whenever you change the source file by deleting the target folder or adding the
--no-partial-parse
flag. This is kinda cumbersome in the dbt Cloud IDE though - each save of a file will do a partial parse behind the scenes.Relevant log output
No response
Environment
Which database adapter are you using with dbt?
postgres
Additional Context
This isn't an issue if we stuck to our good old sql file way of declaring snapshots:
Initial parse:
Modify source like above then reparse:
The text was updated successfully, but these errors were encountered: