You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "zzzk1 (via GitHub)" <gi...@apache.org> on 2024/02/22 15:17:36 UTC
[PR] Support parsing SQL Server SELECT TRIM [shardingsphere]
zzzk1 opened a new pull request, #30249:
URL: https://github.com/apache/shardingsphere/pull/30249
Fixes #29162.
Changes proposed in this pull request:
-
Task
---
This issue is to support more SQL Server sql parsing, as follows:
``` sql
SELECT TRIM( '.,! ' FROM ' # test .') AS Result
```
``` sql
SELECT TRIM(LEADING '.,! ' FROM ' .# test .') AS Result
```
``` sql
SELECT TRIM(TRAILING '.,! ' FROM ' .# test .') AS Result
```
``` sql
SELECT TRIM(BOTH '123' FROM '123abc123') AS Result
```
Before committing this PR, I'm sure that I have checked the following options:
- [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [ ] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the pull request.
- [ ] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
- [ ] I have made corresponding changes to the documentation.
- [ ] I have added corresponding unit tests for my changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support parsing SQL Server SELECT TRIM [shardingsphere]
Posted by "zzzk1 (via GitHub)" <gi...@apache.org>.
zzzk1 commented on PR #30249:
URL: https://github.com/apache/shardingsphere/pull/30249#issuecomment-1962302704
> Hi @zzzk1, can you take a look at #30270, I made some minor optimizations. You can get this code conduct from doc - [shardingsphere.apache.org/community/cn/involved/conduct/code/#g4-%E8%A7%84%E8%8C%83](https://shardingsphere.apache.org/community/cn/involved/conduct/code/#g4-%E8%A7%84%E8%8C%83).
sorry about that i will be prudently next
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support parsing SQL Server SELECT TRIM [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on PR #30249:
URL: https://github.com/apache/shardingsphere/pull/30249#issuecomment-1962286451
Hi @zzzk1, can you take a look at https://github.com/apache/shardingsphere/pull/30270, I made some minor optimizations.
You can get this code conduct from doc - https://shardingsphere.apache.org/community/cn/involved/conduct/code/#g4-%E8%A7%84%E8%8C%83.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support parsing SQL Server SELECT TRIM [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu merged PR #30249:
URL: https://github.com/apache/shardingsphere/pull/30249
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support parsing SQL Server SELECT TRIM [shardingsphere]
Posted by "zzzk1 (via GitHub)" <gi...@apache.org>.
zzzk1 commented on PR #30249:
URL: https://github.com/apache/shardingsphere/pull/30249#issuecomment-1961790225
@strongduanmu pls take a look
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support parsing SQL Server SELECT TRIM [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on code in PR #30249:
URL: https://github.com/apache/shardingsphere/pull/30249#discussion_r1501273606
##########
test/it/parser/src/main/resources/case/dml/select.xml:
##########
@@ -6517,7 +6517,84 @@
<simple-table name="employees" start-index="210" stop-index="218" literal-start-index="210" literal-stop-index="218" />
</from>
</select>
-
+
+ <select sql-case-id="select_with_trim_function2">
+ <projections start-index="7" stop-index="57">
+ <expression-projection text="TRIM( '.,! ' FROM ' # test .')" start-index="7" stop-index="57" alias="Result">
+ <expr>
+ <function function-name="TRIM" start-index="7" stop-index="47" text="TRIM( '.,! ' FROM ' # test .')">
+ <parameter>
+ <literal-expression value=".,! " start-index="13" stop-index="18" />
+ </parameter>
+ <parameter>
+ <literal-expression value=" # test ." start-index="25" stop-index="46" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_with_trim_function3">
+ <projections start-index="7" stop-index="66">
+ <expression-projection text="TRIM(LEADING '.,! ' FROM ' .# test .')" start-index="7" stop-index="66" alias="Result">
+ <expr>
+ <function function-name="TRIM" start-index="7" stop-index="56" text="TRIM(LEADING '.,! ' FROM ' .# test .')">
+ <parameter>
+ <literal-expression value="LEADING" start-index="12" stop-index="18" />
+ </parameter>
+ <parameter>
+ <literal-expression value=".,! " start-index="20" stop-index="25" />
+ </parameter>
+ <parameter>
+ <literal-expression value=" .# test ." start-index="33" stop-index="55" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_with_trim_function4">
+ <projections start-index="7" stop-index="66">
+ <expression-projection text="TRIM(TRAILING '.,! ' FROM ' .# test .')" start-index="7" stop-index="66" alias="Result">
+ <expr>
+ <function function-name="TRIM" start-index="7" stop-index="56" text="TRIM(TRAILING '.,! ' FROM ' .# test .')">
+ <parameter>
+ <literal-expression value="TRAILING" start-index="12" stop-index="19" />
+ </parameter>
+ <parameter>
+ <literal-expression value=".,! " start-index="21" stop-index="26" />
+ </parameter>
+ <parameter>
+ <literal-expression value=" .# test ." start-index="33" stop-index="55" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_with_trim_function5">
Review Comment:
Please rename the sql-case-id with a meaningful name.
##########
parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4:
##########
@@ -315,9 +315,14 @@ distinct
;
specialFunction
- : conversionFunction | charFunction | openJsonFunction | jsonFunction | openRowSetFunction | windowFunction | approxFunction | openDatasourceFunction | rowNumberFunction | graphFunction
+ : conversionFunction | charFunction | openJsonFunction | jsonFunction | openRowSetFunction | windowFunction | approxFunction | openDatasourceFunction | rowNumberFunction | graphFunction | trimFunction
;
+ trimFunction
Review Comment:
Please keep the same indentation as the other rules.
##########
test/it/parser/src/main/resources/case/dml/select.xml:
##########
@@ -6517,7 +6517,84 @@
<simple-table name="employees" start-index="210" stop-index="218" literal-start-index="210" literal-stop-index="218" />
</from>
</select>
-
+
+ <select sql-case-id="select_with_trim_function2">
+ <projections start-index="7" stop-index="57">
+ <expression-projection text="TRIM( '.,! ' FROM ' # test .')" start-index="7" stop-index="57" alias="Result">
+ <expr>
+ <function function-name="TRIM" start-index="7" stop-index="47" text="TRIM( '.,! ' FROM ' # test .')">
+ <parameter>
+ <literal-expression value=".,! " start-index="13" stop-index="18" />
+ </parameter>
+ <parameter>
+ <literal-expression value=" # test ." start-index="25" stop-index="46" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_with_trim_function3">
+ <projections start-index="7" stop-index="66">
+ <expression-projection text="TRIM(LEADING '.,! ' FROM ' .# test .')" start-index="7" stop-index="66" alias="Result">
+ <expr>
+ <function function-name="TRIM" start-index="7" stop-index="56" text="TRIM(LEADING '.,! ' FROM ' .# test .')">
+ <parameter>
+ <literal-expression value="LEADING" start-index="12" stop-index="18" />
+ </parameter>
+ <parameter>
+ <literal-expression value=".,! " start-index="20" stop-index="25" />
+ </parameter>
+ <parameter>
+ <literal-expression value=" .# test ." start-index="33" stop-index="55" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_with_trim_function4">
Review Comment:
Please rename the sql-case-id with a meaningful name.
##########
test/it/parser/src/main/resources/case/dml/select.xml:
##########
@@ -6436,7 +6436,7 @@
</order-by>
</select>
- <select sql-case-id="select_with_trim_function">
+ <select sql-case-id="select_with_trim_function1">
Review Comment:
Please rename the sql-case-id with a meaningful name.
##########
test/it/parser/src/main/resources/case/dml/select.xml:
##########
@@ -6517,7 +6517,84 @@
<simple-table name="employees" start-index="210" stop-index="218" literal-start-index="210" literal-stop-index="218" />
</from>
</select>
-
+
+ <select sql-case-id="select_with_trim_function2">
Review Comment:
Please rename the sql-case-id with a meaningful name.
##########
test/it/parser/src/main/resources/case/dml/select.xml:
##########
@@ -6517,7 +6517,84 @@
<simple-table name="employees" start-index="210" stop-index="218" literal-start-index="210" literal-stop-index="218" />
</from>
</select>
-
+
+ <select sql-case-id="select_with_trim_function2">
+ <projections start-index="7" stop-index="57">
+ <expression-projection text="TRIM( '.,! ' FROM ' # test .')" start-index="7" stop-index="57" alias="Result">
+ <expr>
+ <function function-name="TRIM" start-index="7" stop-index="47" text="TRIM( '.,! ' FROM ' # test .')">
+ <parameter>
+ <literal-expression value=".,! " start-index="13" stop-index="18" />
+ </parameter>
+ <parameter>
+ <literal-expression value=" # test ." start-index="25" stop-index="46" />
+ </parameter>
+ </function>
+ </expr>
+ </expression-projection>
+ </projections>
+ </select>
+
+ <select sql-case-id="select_with_trim_function3">
Review Comment:
Please rename the sql-case-id with a meaningful name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support parsing SQL Server SELECT TRIM [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on PR #30249:
URL: https://github.com/apache/shardingsphere/pull/30249#issuecomment-1960547953
Hi @zzzk1, thank you for your contribution. Please solve ci exception on your local machine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Support parsing SQL Server SELECT TRIM [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on PR #30249:
URL: https://github.com/apache/shardingsphere/pull/30249#issuecomment-1962142338
Hi @zzzk1, thank you for your contribution. I leave some comment, please take a look.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org