Generated diagrams contain the columns alphabetically sorted, which makes it hard to see the PK (typically the first column) and generally it's easier to navigate the model when it matches the actual table structure.
And vice versa, the lists of tables and relations are exported in a random order, which often leads to a lot of changes to a diagram that has no actual changes in the code, or has one relation modified. If we sort tables and relations alphabetically, it will be much easier to control the changes.
When exporting to a specific location, there was an error raised: 'str' object has no attribute 'cwd' when specifying output path.
When running dbt docs generate from non-dbt folder, one can specify DBT_PROJECT_DIR env variable, but dbt-diagrams docs generate still fails in that case.
When generating more than one diagram and many tables, in many cases the diagrams started missing some tables, seemingly randomly.
Changes:
Fix alphabetical sorting of columns, retain source columns order
Add alphabetical sorting of tables and relations to avoid unnecessary changes due to their random ordering
Fix 'str' object has no attribute 'cwd' when specifying output path
Add support for env variable DBT_PROJECT_DIR
Fix missing sorting by diagram before grouping, leading to most tables missing from diagrams in some cases
Motivation:
'str' object has no attribute 'cwd' when specifying output path
.dbt docs generate
from non-dbt folder, one can specify DBT_PROJECT_DIR env variable, butdbt-diagrams docs generate
still fails in that case.Changes: