Here is the correct sequence:
Correct Order
sources:
- name: blue (source definition)
tables:
- name: yellow (table definition)
columns:
- name: red (column definition + tests)
In dbt, source documentation follows a strict YAML hierarchy. At the top level, the sources: key declares that you are defining source metadata. Inside this block, each source is listed as an item beginning with - name:. Therefore, the snippet describing the source (blue) must come immediately after sources:.
Next, dbt requires a tables: block inside each source to define the raw tables belonging to that source. Thus, the snippet containing tables: must follow the source definition. The table description (yellow) is then placed directly under this key because it represents a table within that source.
Finally, dbt allows column-level metadata under a columns: block inside a table definition. Therefore, columns: appears next, followed by the snippet defining a specific column (red) which includes both a description and tests (unique, not_null).
Arranging the YAML in this hierarchical order ensures dbt can correctly assign documentation to the source object, the table object, and the individual column. Misordering these snippets would break the structure and prevent dbt from generating documentation properly.