-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Support parsing SQL Server SELECT COUNT(*) sql #29433
Conversation
@@ -125,12 +126,16 @@ tableReference | |||
; | |||
|
|||
tableFactor | |||
: tableName (AS? alias)? | subquery AS? alias columnNames? | LP_ tableReferences RP_ | |||
: tableName (AS? alias)? |
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.
Hi @TherChenYang Can you refer this doc for g4 code conduct - https://shardingsphere.apache.org/community/en/involved/conduct/code/#contributor-covenant-g4-of-conduct
If a rule’s branch is over than 5, every branch take a new line.
According to g4 code conduct, we should keep these sub rule in one line when the branch is less than 5.
@@ -58,3 +56,5 @@ QUESTION_: '?'; | |||
AT_: '@'; | |||
SEMI_: ';'; | |||
DOLLAR_: '$'; | |||
fragment LBT_: '['; |
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 change it to fragment?
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 was writing g4, LBT_ would be parsed separately, affecting normal syntax rules. I merged the master code and found that the problem had been solved. I would roll back the code
result.setAlias(alias); | ||
return result; | ||
} | ||
|
||
private int getStartIndexWithAlias(final SQLSegment sqlSegment, final AliasSegment alias) { | ||
return alias != null && alias.getStartIndex() < sqlSegment.getStartIndex() ? alias.getStartIndex() : sqlSegment.getStartIndex(); |
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.
Please put null on the left condition.
} | ||
|
||
private int getStopIndexWithAlias(final SQLSegment sqlSegment, final AliasSegment alias) { | ||
return alias != null && alias.getStopIndex() > sqlSegment.getStopIndex() ? alias.getStopIndex() : sqlSegment.getStopIndex(); |
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.
Please put null on the left condition.
@@ -60,12 +60,12 @@ public Optional<IdentifierValue> getAlias() { | |||
|
|||
@Override | |||
public int getStartIndex() { | |||
return column.getStartIndex(); | |||
return alias != null && alias.getStartIndex() < column.getStartIndex() ? alias.getStartIndex() : column.getStartIndex(); |
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.
Please put null on the left condition.
} | ||
|
||
@Override | ||
public int getStopIndex() { | ||
return null == alias ? column.getStopIndex() : alias.getStopIndex(); | ||
return alias != null && alias.getStopIndex() > column.getStopIndex() ? alias.getStopIndex() : column.getStopIndex(); |
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.
Please put null on the left condition.
@@ -83,8 +83,13 @@ public AliasSegment getAliasSegment() { | |||
return alias; | |||
} | |||
|
|||
@Override | |||
public int getStartIndex() { | |||
return alias != null && alias.getStartIndex() < startIndex ? alias.getStartIndex() : startIndex; |
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.
Please put null on the left condition.
@Override | ||
public int getStopIndex() { | ||
return null == alias ? stopIndex : alias.getStopIndex(); | ||
return alias != null && alias.getStopIndex() > stopIndex ? alias.getStopIndex() : stopIndex; |
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.
Please put null on the left condition.
@strongduanmu Thank you, the modifications have been made according to your CR requirements. |
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.
Thank you @TherChenYang for your contribution. This pr looks better now.
Fixes #29170.
Changes proposed in this pull request:
Support parsing SQL Server
Related document
Related document
Before committing this PR, I'm sure that I have checked the following options:
./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e
.