You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
Snapshots defined in a yaml file such as dbt_project/models/schema.yml fail to build/run if a file dbt_project/target/run/dbt_project/models/schema.yml exists:
Unhandled error while executing target/run/dbt_project/models/schema.yml/schema.yml/snapshot.sql
[Errno 20] Not a directory: 'dbt_project/target/run/dbt_project/models/schema.yml/schema.yml'
I'm not sure exactly what causes the schema.yml to end up in the target directory, but it has happened multiple times.
Expected Behavior
Replace . with _ in folder names, i.e. target/run/models/schema_yml/... - ideal because it's clearer than having folders with file extensions or
Check that item in target/run path is folder and handle gracefully (i.e. remove)
For these yml models ParsedNode.get_target_write_path() is running with self.original_file_path = "models/schema.yml" and self.path = "schema.yml/snapshot.sql", which are joined to get the path models/schema.yml/schema.yml/snapshot.sql.
This seems pretty inelegant, a path such as models/schema_yml/snapshot.sql would avoid having directories that look like and might collide with files and remove the extra nesting.
Adding this elif does this - although it probably needs to be more robust.
ifos.path.basename(self.path) ==os.path.basename(self.original_file_path):
# One-to-one relationship of nodes to files.path=self.original_file_pathelifos.path.dirname(self.path) ==os.path.basename(self.original_file_path):
parent_dirname=os.path.dirname(self.original_file_path)
dirname=os.path.dirname(self.path).replace(".", "_")
basename=os.path.basename(self.path)
path=os.path.join(parent_dirname, dirname, basename)
else:
# Many-to-one relationship of nodes to files.path=os.path.join(self.original_file_path, self.path)
The resultant structure is much easier to understand:
Is this a new bug in dbt-core?
Current Behavior
Snapshots defined in a yaml file such as
dbt_project/models/schema.yml
fail to build/run if a filedbt_project/target/run/dbt_project/models/schema.yml
exists:I'm not sure exactly what causes the schema.yml to end up in the target directory, but it has happened multiple times.
Expected Behavior
.
with_
in folder names, i.e.target/run/models/schema_yml/...
- ideal because it's clearer than having folders with file extensions orSteps To Reproduce
Relevant log output
Environment
Which database adapter are you using with dbt?
Reproduced with duckdb and snowflake
Additional Context
If not already known - I'll look at fixing myself and making PR
The text was updated successfully, but these errors were encountered: