You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "TherChenYang (via GitHub)" <gi...@apache.org> on 2023/12/28 02:40:44 UTC

[PR] removing sqlCommentParseEnabled config in SQLParser rule [shardingsphere]

TherChenYang opened a new pull request, #29575:
URL: https://github.com/apache/shardingsphere/pull/29575

   Fixes #29535.
   
   Changes proposed in this pull request:
   - [x] remove sqlCommentParseEnabled in SQL Parser Rule and kernel
   - [x] remove sqlCommentParseEnabled in DistSQL 
   - [x] remove antlr parser Sharding RALStatement sqlCommentParseEnabled
   - [ ]  remove sqlCommentParseEnabled in doc, and update SQL Hint usage description
   ---
   
   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.
   - [ ] 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.
   - [x] 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] removing sqlCommentParseEnabled config in SQLParser rule [shardingsphere]

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu merged PR #29575:
URL: https://github.com/apache/shardingsphere/pull/29575


-- 
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] removing sqlCommentParseEnabled config in SQLParser rule [shardingsphere]

Posted by "TherChenYang (via GitHub)" <gi...@apache.org>.
TherChenYang commented on code in PR #29575:
URL: https://github.com/apache/shardingsphere/pull/29575#discussion_r1437496908


##########
infra/parser/src/test/java/org/apache/shardingsphere/infra/parser/sql/SQLStatementParserEngineFactoryTest.java:
##########
@@ -31,15 +31,15 @@ class SQLStatementParserEngineFactoryTest {
     
     @Test
     void assertGetSQLStatementParserEngineNotSame() {
-        SQLStatementParserEngine before = SQLStatementParserEngineFactory.getSQLStatementParserEngine(databaseType, new CacheOption(2000, 65535L), new CacheOption(128, 1024L), false);
-        SQLStatementParserEngine after = SQLStatementParserEngineFactory.getSQLStatementParserEngine(databaseType, new CacheOption(2000, 65535L), new CacheOption(128, 1024L), true);
+        SQLStatementParserEngine before = SQLStatementParserEngineFactory.getSQLStatementParserEngine(databaseType, new CacheOption(2000, 65535L), new CacheOption(64, 1024L));

Review Comment:
   This test class is for testing the getSqlStatementParserEngine method. If the parameters are different, assertNotSame(before, after) should be used. Originally, the sqlCommentParseEnabled parameter was different: true in before and false in after. In the new code, this parameter sqlCommentParseEnabled has been removed, so the test case needs to be adjusted.



-- 
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] removing sqlCommentParseEnabled config in SQLParser rule [shardingsphere]

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on code in PR #29575:
URL: https://github.com/apache/shardingsphere/pull/29575#discussion_r1437490388


##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java:
##########
@@ -521,8 +521,8 @@ public int[] executeBatch() throws SQLException {
     
     private QueryContext createQueryContext(final String originSQL) {
         SQLParserRule sqlParserRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);
-        String sql = sqlParserRule.isSqlCommentParseEnabled() ? originSQL : SQLHintUtils.removeHint(originSQL);
-        HintValueContext hintValueContext = sqlParserRule.isSqlCommentParseEnabled() ? new HintValueContext() : SQLHintUtils.extractHint(originSQL).orElseGet(HintValueContext::new);
+        String sql = SQLHintUtils.removeHint(originSQL);

Review Comment:
   Is this logic wrong?



##########
infra/parser/src/test/java/org/apache/shardingsphere/infra/parser/sql/SQLStatementParserEngineFactoryTest.java:
##########
@@ -31,15 +31,15 @@ class SQLStatementParserEngineFactoryTest {
     
     @Test
     void assertGetSQLStatementParserEngineNotSame() {
-        SQLStatementParserEngine before = SQLStatementParserEngineFactory.getSQLStatementParserEngine(databaseType, new CacheOption(2000, 65535L), new CacheOption(128, 1024L), false);
-        SQLStatementParserEngine after = SQLStatementParserEngineFactory.getSQLStatementParserEngine(databaseType, new CacheOption(2000, 65535L), new CacheOption(128, 1024L), true);
+        SQLStatementParserEngine before = SQLStatementParserEngineFactory.getSQLStatementParserEngine(databaseType, new CacheOption(2000, 65535L), new CacheOption(64, 1024L));

Review Comment:
   Why change 128 to 64?



-- 
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] removing sqlCommentParseEnabled config in SQLParser rule [shardingsphere]

Posted by "TherChenYang (via GitHub)" <gi...@apache.org>.
TherChenYang commented on code in PR #29575:
URL: https://github.com/apache/shardingsphere/pull/29575#discussion_r1437498345


##########
jdbc/core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java:
##########
@@ -521,8 +521,8 @@ public int[] executeBatch() throws SQLException {
     
     private QueryContext createQueryContext(final String originSQL) {
         SQLParserRule sqlParserRule = metaDataContexts.getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class);
-        String sql = sqlParserRule.isSqlCommentParseEnabled() ? originSQL : SQLHintUtils.removeHint(originSQL);
-        HintValueContext hintValueContext = sqlParserRule.isSqlCommentParseEnabled() ? new HintValueContext() : SQLHintUtils.extractHint(originSQL).orElseGet(HintValueContext::new);
+        String sql = SQLHintUtils.removeHint(originSQL);

Review Comment:
   ![image](https://github.com/apache/shardingsphere/assets/124348939/ac281ef7-81c8-4384-997f-b52e7b64cd83)
   There is a judgment of 'startWith' in removeHint.



-- 
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