You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi community.
The ShardingSphere SQL parser engine helps users to parse SQL to create the AST (Abstract Syntax Tree) and visit the AST to get SQLStatement (Java Object).
Currently, we are planning to enhance the support for MySQL SQL parsing in ShardingSphere.
In the original parsing work, it may have overlooked the parsing of method parameters. For ShardingSphere, we need to pay attention to the table name or field name in method parameters. If there are issues with parsing method parameters, it will cause problems in subsequent binding and rewriting tasks.
For the verification work, we need to complete the following items.
If you intend to participate in fixing this issue, please feel free to leave a comment below the issue. Community members will assign the issue accordingly.
For example, you can leave a comment like this: "Hi, please assign this issue to me. Thank you!"
Once you have claimed the issue, please review the syntax of the SQL on the official website of the corresponding database. Execute the SQL on the respective database to ensure the correctness of the SQL syntax.
You can check the corresponding source of each SQL case on the official database website by clicking on the link provided below each case.
Next, execute the problematic SQL cases mentioned above in the database (you can quickly start the corresponding database using the Docker image for that database, and then connect to it using
a client you are familiar with), to ensure that the SQL syntax itself is correct.
Fixing ANTLR Grammar Parsing Issue
Once you have confirmed the correctness of the SQL syntax, you can validate and fix the grammar parsing issue in ShardingSphere.
If you are using IntelliJ IDEA, you will need to install the ANTLR plugin before proceeding.
If it is an ANTLR parsing error message, try to repair the .g4 file by comparing it with the official database syntax until the SQL can be correctly parsed by ANTLR.
When there is no error message in the ANTLR Preview window, it means that ANTLR can correctly parse the SQL.
Visitor problem fix
After ANTLR parses SQL into an abstract syntax tree, ShardingSphere will access the abstract syntax tree through Visitor and extract the required information.
If you need to extract Segments, you need to first execute:
mvn -T 2C clean install -DskipTests
Under the shardingsphere-parser module to compile the entire parser module.
Then rewrite the corresponding visit method in SQLStatementVisitorr as needed to extract the corresponding Segment.
Add assertion test file
After the above SQL parsing problem is repaired, the corresponding Test needs to be added.
The steps are as follows:
Add the corresponding sql-case in the sql/supported directory.
Add case assertions in the case directory of the shardingsphere-test-it-parser module.
Run org.apache.shardingsphere.test.it.sql.parser.internal.InternalSQLParserIT
After SQL Parser IT runs successfully, you can submit a PR.
Relevant Skills
Master JAVA language
Have a basic understanding of Antlr g4 file
Be familiar with Doris SQLs
The text was updated successfully, but these errors were encountered:
Hi, I'd like to work on this issue if not fixed although I am unable to find the database used to verify the SQL queries. I only found the "employees" database provided by MySQL in it's documentation. Am I supposed to create a test database to verify the syntax of the queries first or is there a pre existing database with which I can complete the verification? Thanks!
Background
Hi community.
The ShardingSphere SQL parser engine helps users to parse SQL to create the AST (Abstract Syntax Tree) and visit the AST to get SQLStatement (Java Object).
Currently, we are planning to enhance the support for MySQL SQL parsing in ShardingSphere.
More details:
https://shardingsphere.apache.org/document/current/en/reference/sharding/parse/
Issue Background Explanation
In the original parsing work, it may have overlooked the parsing of method parameters. For ShardingSphere, we need to pay attention to the table name or field name in method parameters. If there are issues with parsing method parameters, it will cause problems in subsequent binding and rewriting tasks.
For the verification work, we need to complete the following items.
Task
Overall Procedure
If you intend to participate in fixing this issue, please feel free to leave a comment below the issue. Community members will assign the issue accordingly.
Once you have claimed the issue, please review the syntax of the SQL on the official website of the corresponding database. Execute the SQL on the respective database to ensure the correctness of the SQL syntax.
Next, execute the problematic SQL cases mentioned above in the database (you can quickly start the corresponding database using the Docker image for that database, and then connect to it using
a client you are familiar with), to ensure that the SQL syntax itself is correct.
Fixing ANTLR Grammar Parsing Issue
Once you have confirmed the correctness of the SQL syntax, you can validate and fix the grammar parsing issue in ShardingSphere.
If it is an ANTLR parsing error message, try to repair the
.g4
file by comparing it with the official database syntax until the SQL can be correctly parsed by ANTLR.When there is no error message in the ANTLR Preview window, it means that ANTLR can correctly parse the SQL.
Visitor problem fix
After ANTLR parses SQL into an abstract syntax tree, ShardingSphere will access the abstract syntax tree through Visitor and extract the required information.
If you need to extract Segments, you need to first execute:
Under the shardingsphere-parser module to compile the entire parser module.
Then rewrite the corresponding visit method in SQLStatementVisitorr as needed to extract the corresponding Segment.
Add assertion test file
After the above SQL parsing problem is repaired, the corresponding Test needs to be added.
The steps are as follows:
sql-case
in thesql/supported
directory.shardingsphere-test-it-parser
module.org.apache.shardingsphere.test.it.sql.parser.internal.InternalSQLParserIT
After SQL Parser IT runs successfully, you can submit a PR.
Relevant Skills
The text was updated successfully, but these errors were encountered: