Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_toja can not be applied to a named query block & leading hint can not be applied to join children #56724

Open
AilinKid opened this issue Oct 18, 2024 · 0 comments
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@AilinKid
Copy link
Contributor

Enhancement

  • use_toja should be able to be applied to a named query block
  • when we build a join, we will set the preferred join hint, we could see when join child are already a join with merged schema(different table name inside), it couldn't pass the extract alias check
func (p *LogicalJoin) setPreferredJoinTypeAndOrder(hintInfo *tableHintInfo) {
	if hintInfo == nil {
		return
	}

	lhsAlias := extractTableAlias(p.children[0], p.blockOffset)
	rhsAlias := extractTableAlias(p.children[1], p.blockOffset)

func extractTableAlias(p Plan, parentOffset int) *hintTableInfo {
	if len(p.OutputNames()) > 0 && p.OutputNames()[0].TblName.L != "" {
		firstName := p.OutputNames()[0]
		for _, name := range p.OutputNames() {
			if name.TblName.L != firstName.TblName.L ||
				(name.DBName.L != "" && firstName.DBName.L != "" && name.DBName.L != firstName.DBName.L) { // DBName can be nil, see #46160
				return nil
			}
		}

as we see from the extractTableAlias, when the output name contains two different table, it will abort the extracting logic.
that's why case 7458 couldn't succeed.

@AilinKid AilinKid added the type/enhancement The issue or PR belongs to an enhancement. label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant