[ 
https://issues.apache.org/jira/browse/FLINK-24592?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17433499#comment-17433499
 ] 

Sergey Nuyanzin edited comment on FLINK-24592 at 10/24/21, 7:47 PM:
--------------------------------------------------------------------

Currently I have a version[1] supported all the mentioned problem queries.

May be a bit description: there is a continuation prompt from jline3 (FlinkSql 
depends on it).
I introduced the following logic:

||Prompt||Meaning||
|{{Flink SQL>}}|Ready for a new query|
|{{>}}|Waiting for next line of multiple-line query,
        waiting for completion of query with semicolon ({{;}}) |
|{{'>}}|Waiting for next line,
       waiting for completion of a string that began with a single quote 
({{'}}) |
|{{`>}}|Waiting for next line,
       waiting for completion of a string that began with a back tick ({{`}}) |
|{{*\>}} |Waiting for next line,
       waiting for completion of a multi-line comment that began with {{/*}}| 
| {{)>}} | Waiting for next line,
       waiting for completion of a string that began with a round bracket, 
{{(}} |
|{{]>}} |Waiting for next line,
       waiting for completion of a string that began with a square bracket, 
{{[}} |
| {{extra )>}} |There is an extra round bracket {{)}}, that is not opened with 
{{(}} |
| {{extra ]>}} |There is an extra square bracket {{]}}, that is not opened with 
{{[}} |

Currently dialect related info like sql quote identifiers, one line comment is 
hardcoded in constants in {{SqlMultiLineParser}}. 
Probably retrieval of dialect related info from the current dialect could be 
added as further improvement.

+ one more thing: 
currently the idea is to remove oneline and multiline comments from the query 
before execution (there is similar logic in current master for the starting 
one-line comment).
Regarding multiline comments - there is an exception for hints: usual multiline 
comment will be removed. Hints (which are starting with {{/*+}}) will not.

In case there are any other suggestion or feedback - please let me know.
I will try to create a PR this week.

[1] https://github.com/snuyanzin/flink/tree/flinksqlclient


was (Author: sergey nuyanzin):
Currently I have a version[1] supported all the mentioned problem queries.

May be a bit description: there is a continuation prompt from jline3 (FlinkSql 
depends on it).
I introduced the following logic:

||Prompt||Meaning||
|{{Flink SQL>}}|Ready for a new query|
|{{>}}|Waiting for next line of multiple-line query,
        waiting for completion of query with semicolon ({{;}}) |
|{{'>}}|Waiting for next line,
       waiting for completion of a string that began with a single quote 
({{'}}) |
|{{`>}}|Waiting for next line,
       waiting for completion of a string that began with a back tick ({{`}}) |
|{{*\>}} |Waiting for next line,
       waiting for completion of a multi-line comment that began with {{/*}}| 
| {{)>}} | Waiting for next line,
       waiting for completion of a string that began with a round bracket, 
{{(}} |
|{{]>}} |Waiting for next line,
       waiting for completion of a string that began with a square bracket, 
{{[}} |
| {{extra )>}} |There is an extra round bracket {{)}}, that is not opened with 
{{(}} |
| {{extra ]>}} |There is an extra square bracket {{]}}, that is not opened with 
{{[}} |

Currently dialect related info like sql quote identifiers, one line comment is 
hardcoded in constants in {{SqlMultiLineParser}}. 
Probably retrieval of dialect related info from the current dialect could be 
added as further improvement.

In case there are any other suggestion or feedback - please let me know.
I will try to create a PR this week.

[1] https://github.com/snuyanzin/flink/tree/flinksqlclient

> FlinkSQL multiline parser improvements
> --------------------------------------
>
>                 Key: FLINK-24592
>                 URL: https://issues.apache.org/jira/browse/FLINK-24592
>             Project: Flink
>          Issue Type: Improvement
>          Components: Table SQL / Client
>            Reporter: Sergey Nuyanzin
>            Priority: Major
>
> Currently existing multiline parser has limitations e.g.
> line could not end with semicolon e.g. as a part of field value, comment or 
> column name.
> Also if a query contains '--' e.g. as a part of varchar field value then it 
> fails.
> In case there is no objections I would put some efforts to improve this 
> behavior;
> here it is a list of sample problem queries
> {code:sql}
> select 123; -- comment
> select 1 as `1--`;
> select '--';
> -- This query works if a user copy-pastes it to FlinkSQL, however it fails if 
> a user types it in FlinkSQL
> select '1;
> ';
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to