Skip to content

fix:[SNOW-3444080] Preserve customer's original key order inside profiles.yml and env.yml; Refactor some code#3130

Draft
sfc-gh-yuding wants to merge 1 commit into
mainfrom
fix/dbt-yaml-staging-fixes
Draft

fix:[SNOW-3444080] Preserve customer's original key order inside profiles.yml and env.yml; Refactor some code#3130
sfc-gh-yuding wants to merge 1 commit into
mainfrom
fix/dbt-yaml-staging-fixes

Conversation

@sfc-gh-yuding

@sfc-gh-yuding sfc-gh-yuding commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Pre-review checklist

  • If my changes add or modify user-facing interface (commands, flags, output formats), I consulted maintainers and got sign-off beforehand (how).
    No user-facing interface change
  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • Manually tested on macOS
  • Manually tested on Windows
  • I've confirmed my changes are up-to-date with the target branch.
  • I've described my changes in RELEASE-NOTES.md (see when and how).
    Updated RELEASE-NOTES.md for profiles.yml changes. As for env.yaml, it's a prpr change, will include it in the RELEASE-NOTES.md when it becomes GA
  • I've updated documentation if behavior changed.
    No behavior change

Changes description

Verified on QA6 (DEXQA6) using the fix/dbt-yaml-staging-fixes branch.

Test files

profiles.yml — keys in a deliberately non-alphabetical order
(type → threads → account → user → password → role → warehouse → database → schema).
Alphabetical order would be account < database < password < role < schema < threads < type < user < warehouse.

env.yml — DBT_* keys in reverse-alphabetical order (ZETA → GAMMA → ALPHA → BETA).
Alphabetical order would be ALPHA < BETA < GAMMA < ZETA.


Deploy
snow dbt deploy yuding_order_preservation_test --source ./dbt_order_test --force

Verify staged file contents
snow sql -q "GET snow://dbt/YUDING_TEST.PUBLIC.YUDING_ORDER_PRESERVATION_TEST/versions/version\$1/profiles.yml file://$HOME/staged/"
snow sql -q "GET snow://dbt/YUDING_TEST.PUBLIC.YUDING_ORDER_PRESERVATION_TEST/versions/version\$1/env.yml    file://$HOME/staged/"
Staged profiles.yml

Key order matches the input (type before account, threads before database). ✅

Staged env.yml

Key order matches the input (ZETA → GAMMA → ALPHA → BETA, not sorted). ✅

@sfc-gh-yuding sfc-gh-yuding force-pushed the fix/dbt-yaml-staging-fixes branch from c69aa0e to 6718bfd Compare June 22, 2026 23:03
@sfc-gh-yuding sfc-gh-yuding marked this pull request as ready for review June 22, 2026 23:15
@sfc-gh-yuding sfc-gh-yuding requested review from a team as code owners June 22, 2026 23:15
@sfc-gh-yuding sfc-gh-yuding marked this pull request as draft June 23, 2026 18:23
…staging

- Extract repeated singular/plural logic into _plural(count, word) helper
  to avoid repeating the ternary three times (per PR #3125 review comment)
- Pass sort_keys=False to yaml.safe_dump in _prepare_profiles_file and
  _write_env_file so staged files preserve the customer's original key
  order instead of sorting alphabetically

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sfc-gh-yuding sfc-gh-yuding force-pushed the fix/dbt-yaml-staging-fixes branch from 6718bfd to c7792dc Compare June 25, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant