You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by "sjgllgh (via GitHub)" <gi...@apache.org> on 2023/11/15 07:28:48 UTC
[PR] sql field comment semicolon with escape [linkis]
sjgllgh opened a new pull request, #4967:
URL: https://github.com/apache/linkis/pull/4967
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.
You can learn more about contributing to Apache Linkis here: https://linkis.apache.org/community/how-to-contribute
Happy contributing!
-->
### Related issues/PRs
Related issues: #4966
### Brief change log
- Define regular syntax, match sql statement field comments, and escape;
### Checklist
- [x] I have read the [Contributing Guidelines on pull requests](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#pull-requests).
- [ ] I have explained the need for this PR and the problem it solves
- [ ] I have explained the changes or the new features added to this PR
- [ ] I have added tests corresponding to this change
- [ ] I have updated the documentation to reflect this change
- [ ] I have verified that this change is backward compatible (If not, please discuss on the [Linkis mailing list](https://linkis.apache.org/community/how-to-subscribe) first)
- [ ] **If this is a code change**: I have written unit tests to fully verify the new behavior.
<!--
Note
1. Mark the PR title as `[WIP] title` until it's ready to be reviewed.
如果PR还未准备好被review,请在标题上添加[WIP]标识(WIP work in progress)
2. Always add/update tests for any changes unless you have a good reason.
除非您有充分的理由,否则任何修改都需要添加/更新测试
3. Always update the documentation to reflect the changes made in the PR.
始终更新文档以反映 PR 中所做的更改
4. After the PR is submitted, please pay attention to the execution result of git action check.
If there is any failure, please adjust it in time
PR提交后,请关注git action check 执行结果,关键的check失败时,请及时修正
5. Before the pr is merged, if the commit is missing, you can continue to commit the code
在未合并前,如果提交有遗漏,您可以继续提交代码
6. After you submit PR, you can add assistant WeChat, the WeChat QR code is
https://user-images.githubusercontent.com/7869972/176336986-d6b9be8f-d1d3-45f1-aa45-8e6adf5dd244.png
您提交pr后,可以添加助手微信,微信二维码为
https://user-images.githubusercontent.com/7869972/176336986-d6b9be8f-d1d3-45f1-aa45-8e6adf5dd244.png
-->
--
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@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] sql field comment semicolon with escape [linkis]
Posted by "peacewong (via GitHub)" <gi...@apache.org>.
peacewong merged PR #4967:
URL: https://github.com/apache/linkis/pull/4967
--
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@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] sql field comment semicolon with escape [linkis]
Posted by "casionone (via GitHub)" <gi...@apache.org>.
casionone commented on PR #4967:
URL: https://github.com/apache/linkis/pull/4967#issuecomment-1831088739
run `mvn spoltess:apply` to fix the failed action

--
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@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] sql field comment semicolon with escape [linkis]
Posted by "sjgllgh (via GitHub)" <gi...@apache.org>.
sjgllgh commented on code in PR #4967:
URL: https://github.com/apache/linkis/pull/4967#discussion_r1408676239
##########
linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala:
##########
@@ -70,8 +70,32 @@ trait CommentHelper {
object SQLCommentHelper extends CommentHelper {
override val commentPattern: Regex = """\s*--.+\s*""".r.unanchored
private val comment = "(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/|#.*?$|"
+ private val comment_sem = "(?i)(comment)\\s+'([^']*)'"
private val logger: Logger = LoggerFactory.getLogger(getClass)
+ def replaceComment(code: String): String = {
+ try {
+ val pattern = Pattern.compile(comment_sem)
+ val matcher = pattern.matcher(code)
+ val sb = new StringBuffer
+ while (matcher.find()) {
+ val commentKeyword = matcher.group(1)
+ val comment = matcher.group(2)
+ val escapedComment = comment.replaceAll(";", "\\\\\\\\;")
Review Comment:
Please review again.Thanks!
--
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@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] sql field comment semicolon with escape [linkis]
Posted by "casionone (via GitHub)" <gi...@apache.org>.
casionone commented on code in PR #4967:
URL: https://github.com/apache/linkis/pull/4967#discussion_r1403470613
##########
linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala:
##########
@@ -70,8 +70,32 @@ trait CommentHelper {
object SQLCommentHelper extends CommentHelper {
override val commentPattern: Regex = """\s*--.+\s*""".r.unanchored
private val comment = "(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/|#.*?$|"
+ private val comment_sem = "(?i)(comment)\\s+'([^']*)'"
private val logger: Logger = LoggerFactory.getLogger(getClass)
+ def replaceComment(code: String): String = {
+ try {
Review Comment:
better to add junit test case for this new function
--
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@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] sql field comment semicolon with escape [linkis]
Posted by "casionone (via GitHub)" <gi...@apache.org>.
casionone commented on code in PR #4967:
URL: https://github.com/apache/linkis/pull/4967#discussion_r1408643307
##########
linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala:
##########
@@ -70,8 +70,32 @@ trait CommentHelper {
object SQLCommentHelper extends CommentHelper {
override val commentPattern: Regex = """\s*--.+\s*""".r.unanchored
private val comment = "(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/|#.*?$|"
+ private val comment_sem = "(?i)(comment)\\s+'([^']*)'"
private val logger: Logger = LoggerFactory.getLogger(getClass)
+ def replaceComment(code: String): String = {
+ try {
+ val pattern = Pattern.compile(comment_sem)
+ val matcher = pattern.matcher(code)
+ val sb = new StringBuffer
+ while (matcher.find()) {
+ val commentKeyword = matcher.group(1)
+ val comment = matcher.group(2)
+ val escapedComment = comment.replaceAll(";", "\\\\\\\\;")
Review Comment:
batter to add some comments to explain for using "\\\\\\\\" (eight \)
--
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@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] sql field comment semicolon with escape [linkis]
Posted by "sjgllgh (via GitHub)" <gi...@apache.org>.
sjgllgh commented on code in PR #4967:
URL: https://github.com/apache/linkis/pull/4967#discussion_r1405908297
##########
linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala:
##########
@@ -70,8 +70,32 @@ trait CommentHelper {
object SQLCommentHelper extends CommentHelper {
override val commentPattern: Regex = """\s*--.+\s*""".r.unanchored
private val comment = "(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/|#.*?$|"
+ private val comment_sem = "(?i)(comment)\\s+'([^']*)'"
private val logger: Logger = LoggerFactory.getLogger(getClass)
+ def replaceComment(code: String): String = {
+ try {
Review Comment:
ok,I do
##########
linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala:
##########
@@ -70,8 +70,32 @@ trait CommentHelper {
object SQLCommentHelper extends CommentHelper {
override val commentPattern: Regex = """\s*--.+\s*""".r.unanchored
private val comment = "(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/|#.*?$|"
+ private val comment_sem = "(?i)(comment)\\s+'([^']*)'"
private val logger: Logger = LoggerFactory.getLogger(getClass)
+ def replaceComment(code: String): String = {
+ try {
Review Comment:
ok,I do
--
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@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] sql field comment semicolon with escape [linkis]
Posted by "sjgllgh (via GitHub)" <gi...@apache.org>.
sjgllgh commented on code in PR #4967:
URL: https://github.com/apache/linkis/pull/4967#discussion_r1408676239
##########
linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala:
##########
@@ -70,8 +70,32 @@ trait CommentHelper {
object SQLCommentHelper extends CommentHelper {
override val commentPattern: Regex = """\s*--.+\s*""".r.unanchored
private val comment = "(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/|#.*?$|"
+ private val comment_sem = "(?i)(comment)\\s+'([^']*)'"
private val logger: Logger = LoggerFactory.getLogger(getClass)
+ def replaceComment(code: String): String = {
+ try {
+ val pattern = Pattern.compile(comment_sem)
+ val matcher = pattern.matcher(code)
+ val sb = new StringBuffer
+ while (matcher.find()) {
+ val commentKeyword = matcher.group(1)
+ val comment = matcher.group(2)
+ val escapedComment = comment.replaceAll(";", "\\\\\\\\;")
Review Comment:
Please review again.Thanks!
--
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@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] sql field comment semicolon with escape [linkis]
Posted by "sjgllgh (via GitHub)" <gi...@apache.org>.
sjgllgh commented on code in PR #4967:
URL: https://github.com/apache/linkis/pull/4967#discussion_r1408674800
##########
linkis-computation-governance/linkis-entrance/src/main/scala/org/apache/linkis/entrance/interceptor/impl/CommentInterceptor.scala:
##########
@@ -70,8 +70,32 @@ trait CommentHelper {
object SQLCommentHelper extends CommentHelper {
override val commentPattern: Regex = """\s*--.+\s*""".r.unanchored
private val comment = "(?ms)('(?:''|[^'])*')|--.*?$|/\\*.*?\\*/|#.*?$|"
+ private val comment_sem = "(?i)(comment)\\s+'([^']*)'"
private val logger: Logger = LoggerFactory.getLogger(getClass)
+ def replaceComment(code: String): String = {
+ try {
+ val pattern = Pattern.compile(comment_sem)
+ val matcher = pattern.matcher(code)
+ val sb = new StringBuffer
+ while (matcher.find()) {
+ val commentKeyword = matcher.group(1)
+ val comment = matcher.group(2)
+ val escapedComment = comment.replaceAll(";", "\\\\\\\\;")
Review Comment:
Please review again.Thanks!
--
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@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org