You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@linkis.apache.org by GitBox <gi...@apache.org> on 2022/04/07 11:02:02 UTC

[GitHub] [incubator-linkis] CCweixiao opened a new issue, #1923: [Bug] [1.x.x] SQLCodeParser sql execution fails when comment contains semicolon.

CCweixiao opened a new issue, #1923:
URL: https://github.com/apache/incubator-linkis/issues/1923

   ### Search before asking
   
   - [X] I searched the [issues](https://github.com/apache/incubator-linkis/issues) and found no similar issues.
   
   
   ### Linkis Component
   
   linkis-commons
   
   ### What happened + What you expected to happen
   
   <img width="835" alt="企业微信截图_82b916d8-2c17-4ed3-9e10-5c8e46a4aa61" src="https://user-images.githubusercontent.com/27730211/162184420-11e19d05-c54d-43b4-b91f-aa0f1baac82e.png">
   
   SQLCodeParser 中的parse方法分隔sql时,如果注释文本中含有;,会被误分隔成sql提交到引擎去执行,是否可以增加一个过滤机制,过滤掉sql中的注释文本呢?
   
   When the parse method in SQLCodeParser separates sql, if the comment text contains ;, it will be mistakenly separated into sql and submitted to the engine for execution. Is it possible to add a filtering mechanism to filter out the comment text in sql?
   
   ### Relevent platform
   
   OS platform
   
   ### Reproduction script
   
   ```java
     val parser = new SQLCodeParser
       val sqlString =
         """
           |-- select device_id, client_id, stats_uv_day,
           |-- stats_uv_week,
           |-- stats_uv_month
           |-- from kbase.dw_cs_devicetag_lanuch_all_v2_presto limit 10;
           |-- select device_id,
           |-- stats_uv
           |-- from kbase.edw_user_dws_cs_device_person_tag_df limit 10;
           |select *
           |-- 这是一条注释
           |from test.edw_behavior_dws_cs_device_retention_dim2_7d_di_presto
           |limit 10;
           |select * from test.leo_test
           |-- 这是注释
           |/** 这也是注释 **/
           |limit 10
           |""".stripMargin
   
       val p = Pattern.compile("(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/");
       val result = p.matcher(sqlString).replaceAll("$1")
       val strings = parser.parse(result)
   ```
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] Yes I am willing to submit a PR!


-- 
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: dev-unsubscribe@linkis.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@linkis.apache.org
For additional commands, e-mail: dev-help@linkis.apache.org


[GitHub] [incubator-linkis] peacewong closed issue #1923: [Bug] [1.x.x] SQLCodeParser sql execution fails when comment contains semicolon.

Posted by GitBox <gi...@apache.org>.
peacewong closed issue #1923: [Bug] [1.x.x] SQLCodeParser sql execution fails when comment contains semicolon.
URL: https://github.com/apache/incubator-linkis/issues/1923


-- 
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: dev-unsubscribe@linkis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@linkis.apache.org
For additional commands, e-mail: dev-help@linkis.apache.org