-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[feat](Nereids) support nereids hint position detaction #39113
Conversation
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
run buildall |
TPC-H: Total hot run time: 40231 ms
|
run buildall |
TPC-H: Total hot run time: 40374 ms
|
TPC-DS: Total hot run time: 209400 ms
|
ClickBench: Total hot run time: 31.57 s
|
@@ -72,6 +72,19 @@ lexer grammar DorisLexer; | |||
public void markUnclosedComment() { | |||
has_unclosed_bracketed_comment = true; | |||
} | |||
|
|||
// This variable will hold the external state | |||
private boolean channel2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why need this var? i think we should always let hint go to channel 2 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when i let channel 2 always open, it would have problem when parsing because in channel lexer would add some char before original string to let parser ignore it. For example: it would make "/* leading(t1 t2) */" into "[@-1,15:36 = '/leading(t1 t2) */', xxx" which when i want to parse it, i would meet eof first then parse exit. So it make a switch to control this behavior
@@ -56,6 +56,10 @@ | |||
|
|||
/**LogicalPlanBuilderForCreateView*/ | |||
public class LogicalPlanBuilderForCreateView extends LogicalPlanBuilder { | |||
public LogicalPlanBuilderForCreateView() { | |||
super(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it should use hint too? for example we could use hint to change sql mode, if create view cannot process it correctly it could generate wrong column type. or cannot analyze create view statement correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -49,6 +49,10 @@ | |||
public class LogicalPlanBuilderForSyncMv extends LogicalPlanBuilder { | |||
private Optional<String> querySql; | |||
|
|||
public LogicalPlanBuilderForSyncMv() { | |||
super(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as create view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
DorisLexer hintLexer = new DorisLexer(new CaseInsensitiveStream(CharStreams.fromString(sql))); | ||
hintLexer.setChannel2(true); | ||
CommonTokenStream hintTokenStream = new CommonTokenStream(hintLexer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
antlr could generate one stream and get specific channel token from it by getHiddenTokensToRight
, so could we use it to get hint in visitRegularQuerySpecification
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getHiddenTokensToRight does not work in this case, I tried to get it but it failed. I try to use List hintTokens = hintTokenStream.getHiddenTokensToRight(0, 2); but it failed to get token list out from channel2
CommonTokenStream newHintTokenStream = new CommonTokenStream(newHintLexer); | ||
DorisParser hintParser = new DorisParser(newHintTokenStream); | ||
ParserRuleContext hintContext = parseFunction.apply(hintParser); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could write a new parser to process hint seperately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is no need to write a new parser but use exist parser logic as hint syntax, the only thing we need to care about is position and new hint type, position is solved by selectHintMap we added, new hint type is filtered by original hint parser. So it is no needed to add a new parser with same logic, we can only use channel 2 to deal with hint seperately
@@ -36,6 +36,10 @@ | |||
*/ | |||
public class PLSqlLogicalPlanBuilder extends LogicalPlanBuilder { | |||
|
|||
public PLSqlLogicalPlanBuilder() { | |||
super(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as create view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
run buildall |
TPC-H: Total hot run time: 40108 ms
|
TPC-DS: Total hot run time: 207614 ms
|
ClickBench: Total hot run time: 31.14 s
|
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
run buildall |
TPC-H: Total hot run time: 40782 ms
|
TPC-DS: Total hot run time: 196162 ms
|
ClickBench: Total hot run time: 31.34 s
|
234725c
to
2e14ee4
Compare
run buildall |
TPC-H: Total hot run time: 40220 ms
|
PR approved by at least one committer and no changes requested. |
When use hint in wrong position or use unsupport hint, use channel(2) to filter it out
When use hint in wrong position or use unsupport hint, use channel(2) to filter it out
When use hint in wrong position or use unsupport hint, use channel(2) to filter it out
When use hint in wrong position or use unsupport hint, use channel(2) to filter it out
When use hint in wrong position or use unsupport hint, use channel(2) to filter it out
…duplicate (apache#39590) nereids timeout cause of parser cost too long time intro by: apache#39113 ## Proposed changes Issue Number: close #xxx <!--Describe your changes.-->
When use hint in wrong position or use unsupport hint, use channel(2) to filter it out
…duplicate (apache#39590) nereids timeout cause of parser cost too long time intro by: apache#39113 ## Proposed changes Issue Number: close #xxx <!--Describe your changes.-->
apache#39416) cherry-pick from master apache#39113 When use hint in wrong position or use unsupport hint, use channel(2) to filter it out
When use hint in wrong position or use unsupport hint, use channel(2) to filter it out