You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "BykaWF (via GitHub)" <gi...@apache.org> on 2023/11/28 23:54:27 UTC
[PR] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
BykaWF opened a new pull request, #29230:
URL: https://github.com/apache/shardingsphere/pull/29230
Fixes #29194.
Changes proposed in this pull request:
It adds support for parsing the following SQL Server INSERT INTO statements:
INSERT INTO #MyTempTable VALUES (1)
INSERT INTO #t VALUES (2)
SELECT Test2Col = x FROM #t
INSERT INTO #t VALUES (1)
SELECT Test1Col = x FROM #t
---
Before committing this PR, I'm sure that I have checked the following options:
- [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [x] I have self-reviewed the commit code.
- [x] I have (or in comment I request) added corresponding labels for the pull request.
- [x] 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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1837460457
> IDENTIFIER_
Hi @BykaWF, What does `#` mean in SQLServer dialect?
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu closed pull request #29230: Added Support for SQL Server INSERT INTO Parsing
URL: https://github.com/apache/shardingsphere/pull/29230
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "BykaWF (via GitHub)" <gi...@apache.org>.
BykaWF commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1837209500
I've encountered an issue during testing where I consistently receive the following error:
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on code in PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#discussion_r1408603319
##########
test/it/parser/src/main/resources/case/dml/insert.xml:
##########
@@ -2900,4 +2900,36 @@
</from>
</select>
</insert>
+ <insert sql-case-id="insert_into_my_temp_table_1">
Review Comment:
Where is the orginal sql?
##########
parser/sql/dialect/sqlserver/src/main/antlr4/imports/sqlserver/BaseRule.g4:
##########
@@ -154,6 +154,10 @@ tableName
: (owner DOT_)? name
;
+tempTableName
Review Comment:
What is the different between tableName and tempTableName?
##########
test/it/parser/src/main/resources/case/dml/insert.xml:
##########
@@ -2900,4 +2900,36 @@
</from>
</select>
</insert>
+ <insert sql-case-id="insert_into_my_temp_table_1">
+ <table name="#MyTempTable" start-index="12" stop-index="25" />
+ <values>
+ <value>
+ <assignment-value>
+ <literal-expression value="1" start-index="31" stop-index="31" />
+ </assignment-value>
+ </value>
+ </values>
+ </insert>
+
+ <insert sql-case-id="insert_into_temp_table_2">
Review Comment:
Please rename sql-case-id to more meaningful name.
##########
test/it/parser/src/main/resources/case/dml/select-expression.xml:
##########
@@ -3125,4 +3125,51 @@
</expression-projection>
</projections>
</select>
+
+ <select sql-case-id="select_from_temporary_table_Test2Col_equals_x">
+ <projections start-index="7" stop-index="19">
+ <expression-projection start-index="7" stop-index="19" text="Test2Col = x">
+ <expr>
+ <binary-operation-expression start-index="7" stop-index="19">
+ <left>
+ <column name="Test2Col" start-index="7" stop-index="13"/>
+ </left>
+ <operator>=</operator>
+ <right>
+ <column name="x" start-index="17" stop-index="18"/>
+ </right>
+ </binary-operation-expression>
+ </expr>
+ </expression-projection>
+ </projections>
+ <from>
+ <simple-table name="#t" start-index="23" stop-index="25">
Review Comment:
Please use `<simple-table><simple-table />` if it doesn't have child node.
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "TherChenYang (via GitHub)" <gi...@apache.org>.
TherChenYang commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1853449392
@strongduanmu @BykaWF
` org.apache.shardingsphere.sql.parser.exception.SQLParsingException: You have an error in your SQL syntax: SELECT Test1Col = x FROM #t, no viable alternative at input '<EOF>' at line 1, position 27, near [@6,27:26='<EOF>',<-1>,1:27]`
This problem is because # is set to comment in Comment.g4, but there are only two annotation rules An and B in the syntax of sqlServer, and there is no #, so this problem occurs. You can refer to this pr #29394
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1867383399
Hi @BykaWF, can you solve code conflict?
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "BykaWF (via GitHub)" <gi...@apache.org>.
BykaWF commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1892568151
Hi @strongduanmu, yes I can
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "BykaWF (via GitHub)" <gi...@apache.org>.
BykaWF commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1837465508
@strongduanmu In SQL Server, the # symbol means temporary tables, which are session-specific and automatically dropped when the session ends.
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1956073134
Since this pr has long time no response, I will close it. You can submit new pr when you are free.
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "TherChenYang (via GitHub)" <gi...@apache.org>.
TherChenYang commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1853360923
> I've encountered an issue during testing where I consistently receive the following error:
>
> ```
> org.apache.shardingsphere.sql.parser.exception.SQLParsingException: You have an error in your SQL syntax: SELECT Test1Col = x FROM #t, no viable alternative at input '<EOF>' at line 1, position 27, near [@6,27:26='<EOF>',<-1>,1:27]
> ```
>
> Could someone provide a hint or suggestions on what might be causing this issue? I think parser doesn't get it what is `'#'`, but I have tried add '#' to IDENTIFIER_ to tableName.
I ran into the same problem that this sql can be parsed in the antlr plugin but will get an error when parsed using a Parser


--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "BykaWF (via GitHub)" <gi...@apache.org>.
BykaWF commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1868372948
I've addressed the issues pointed out in the previous review. Could you please review this updated version? Thank you!
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1891229516
Hi @BykaWF, can you solve the latest code conflict?
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "BykaWF (via GitHub)" <gi...@apache.org>.
BykaWF commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1854526843
@TherChenYang thanks for helping
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1837470154
> @strongduanmu In SQL Server, the # symbol means temporary tables, which are session-specific and automatically dropped when the session ends.
@BykaWF Thank you for your explaination, I think you can add a temp table rule for this case.
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "BykaWF (via GitHub)" <gi...@apache.org>.
BykaWF commented on PR #29230:
URL: https://github.com/apache/shardingsphere/pull/29230#issuecomment-1837210941
I've encountered an issue during testing where I consistently receive the following error:
org.apache.shardingsphere.sql.parser.exception.SQLParsingException: You have an error in your SQL syntax: SELECT Test1Col = x FROM #t, no viable alternative at input '<EOF>' at line 1, position 27, near [@6,27:26='<EOF>',<-1>,1:27]
Could someone provide a hint or suggestions on what might be causing this issue? I think parser doesn't get it what is `'#'`, but I have tried add '#' to IDENTIFIER_ to tableName.
--
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] Added Support for SQL Server INSERT INTO Parsing [shardingsphere]
Posted by "BykaWF (via GitHub)" <gi...@apache.org>.
BykaWF closed pull request #29230: Added Support for SQL Server INSERT INTO Parsing
URL: https://github.com/apache/shardingsphere/pull/29230
--
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