Reconcile original and plan-derived LEADING hints in EXPLAIN FORMAT=hint
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Problem
`EXPLAIN FORMAT='hint'` currently appends table hints extracted from the original statement to hints derived from the physical plan. If the original statement already contains a `LEADING` hint, this can output both the original and plan-derived `LEADING` hints. Replaying that output rejects the duplicate `LEADING` hints instead of reproducing the plan.
## Expected behavior
Reconcile/deduplicate original-statement and plan-derived `LEADING` hints before formatting the result, so the generated hint text remains replayable.
## Scope
- Define precedence/reconciliation semantics when both sources contain `LEADING`.
- Avoid emitting duplicate/conflicting `LEADING` hints.
- Add round-trip tests for statements that already contain `LEADING`.
This is intentionally tracked separately from derived-table alias recovery and CTE hint handling.
Contributor guide
Research direction
Start from the EXPLAIN FORMAT='hint' path and trace where original-statement and physical-plan hints are combined. Define precedence for duplicate or conflicting LEADING hints, then add round-trip tests showing that statements with an existing LEADING hint produce replayable, non-duplicated output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100