Skip to content

parser: support query block in hint#491

Merged
alivxxx merged 3 commits into
pingcap:masterfrom
alivxxx:query-block
Aug 22, 2019
Merged

parser: support query block in hint#491
alivxxx merged 3 commits into
pingcap:masterfrom
alivxxx:query-block

Conversation

@alivxxx
Copy link
Copy Markdown
Contributor

@alivxxx alivxxx commented Aug 16, 2019

What problem does this PR solve?

Support query block syntax in hint.

What is changed and how it works?

Add optional query block as arugments for each hint.

Check List

Tests

  • Unit test

Code changes

  • Has exported function/method change

Side effects

  • None

Related changes

  • None

Comment thread ast/misc.go
// HintTable is table in the hint. It may have query block info.
type HintTable struct {
TableName model.CIStr
QBName model.CIStr
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need we save the QBName in both HintTable and TableOptimizerHint?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we can specify the QB within which the hint will take effect, and also specify a table in some QB?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example: /*+ HASH_JOIN(@sel1 t1, t2) */ and /*+ HASH_JOIN(t1@sel1, t2@sel2).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you can take a look at the test.

Comment thread parser.y

TableOptimizerHintOpt:
index '(' HintTableAndIndexList ')'
index '(' QueryBlockOpt HintTable IndexNameList ')'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have other way to do this? INDEX(@sel_1 t idx1, idx2, idx3) looks weird. Because IndexNameList here can not be empty, we can split by comma.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be empty now.

Comment thread parser.y
$$ = model.NewCIStr("")
}
| HintTableAndIndexList ',' Identifier
| singleAtIdentifier
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether we can use comma to split arguments in SQL hints too, it looks better.

Suggested change
| singleAtIdentifier
| singleAtIdentifier
{
$$ = model.NewCIStr($1)
}
| singleAtIdentifier ‘,’

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, even if you want ,, it should not be put here.

@alivxxx alivxxx requested review from foreyes and lzmhhh123 August 21, 2019 06:17
Comment thread parser.y
hintEnablePlanCache "ENABLE_PLAN_CACHE"
hintUsePlanCache "USE_PLAN_CACHE"
hintReadConsistentReplica "READ_CONSISTENT_REPLICA"
hintQBName "QB_NAME"
Copy link
Copy Markdown
Contributor

@lzmhhh123 lzmhhh123 Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against using QBName in misc.go. But could we use the full name in parser.y to make its mean more clear?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But full name would make using it harder beacause queryblock has 10 chars, it is reasonable trade off I think.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean change hintQBName "QB_NAME" to hintQBName "QUERY_BLOCK_NAME".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also what I means, It contains 8 + 1 more chars that QB_NAME.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right...

Copy link
Copy Markdown
Contributor

@lzmhhh123 lzmhhh123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Copy Markdown
Contributor

@foreyes foreyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't care a lot about args format, LGTM

@alivxxx
Copy link
Copy Markdown
Contributor Author

alivxxx commented Aug 21, 2019

@foreyes We can change it latter needed. Please approve it.

Copy link
Copy Markdown
Contributor

@foreyes foreyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alivxxx alivxxx merged commit 41d48df into pingcap:master Aug 22, 2019
@alivxxx alivxxx deleted the query-block branch August 22, 2019 02:41
foreyes pushed a commit to foreyes/parser that referenced this pull request Sep 16, 2019
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
lyonzhi pushed a commit to lyonzhi/parser that referenced this pull request Apr 25, 2024
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.

3 participants