Skip to content

[BUGFIX] deduplicate sql metric aliases to prevent view schema collisions (#10926)#11905

Open
TemidayoA wants to merge 2 commits into
great-expectations:developfrom
TemidayoA:fix/10926-sql-alias-deduplication
Open

[BUGFIX] deduplicate sql metric aliases to prevent view schema collisions (#10926)#11905
TemidayoA wants to merge 2 commits into
great-expectations:developfrom
TemidayoA:fix/10926-sql-alias-deduplication

Conversation

@TemidayoA

Copy link
Copy Markdown

Closes #10926

Description of Changes:
This PR addresses the schema collision error (Duplicated field name in view schema) that occurs when the SQL execution engine bundles multiple expectations evaluating the same underlying metric. Previously, the query compiler assigned identical SQL aliases to these metrics, causing strict SQL backends (like Postgres) to reject the view/subquery construction.

This fix introduces a dynamic alias deduplication step within _organize_metrics_by_domain. It tracks existing_aliases in the current query batch and automatically appends an incrementing suffix (e.g., _1, _2) to any colliding metric names before attaching the .label(), allowing the SQL view to compile successfully without breaking downstream positional index mapping.

  • Description of PR changes above includes a link to an existing GitHub issue
  • PR title is prefixed with one of: [BUGFIX], [FEATURE], [DOCS], [MAINTENANCE], [CONTRIB], [MINORBUMP]
  • Code is linted - run invoke lint (uses ruff format + ruff check)
  • Appropriate tests and docs have been updated

@netlify

netlify Bot commented Jun 4, 2026

Copy link
Copy Markdown

👷 Deploy request for niobium-lead-7998 pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 6c8957f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant