Flink SQL解析问题

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Flink SQL解析问题

Senior.Hu
Hi All,
  在用FlinkSqlParserImpl.FACTORY解析Flink DML SQL时,发现解析Join with Temporal Table语法,会自动加上LATERAL关键字,如下所示
  LEFT JOIN
        side_room FOR SYSTEM_TIME AS OF a1.proctime as a2
    ON
        a1.rowkey_room = a2.rowkey
  解析后变成如下:
  LEFT JOIN LATERAL `side_room` FOR SYSTEM_TIME AS OF `a1`.`proctime` AS `a2` ON `a1`.`rowkey_room` = `a2`.`rowkey`
  
  此SQL语法在Flink SQL中执行会报错如下:
  Caused by: org.apache.flink.table.api.SqlParserException: SQL parse failed. Encountered "`side_room`" at line 7, column 19.
  Was expecting one of:
    "TABLE" ...
    "(" ...
  
 我的SqlParser.Config类定义如下:
 private final SqlParser.Config config = SqlParser.configBuilder()
            .setParserFactory(FlinkSqlParserImpl.FACTORY)
            .setQuoting(Quoting.BACK_TICK)
            .setUnquotedCasing(Casing.UNCHANGED)
            .setQuotedCasing(Casing.UNCHANGED)
            .setCaseSensitive(true)
            .build();
  
  不知道这个地方为什么会出现这种情况,或者是我这边使用方法不对?
Reply | Threaded
Open this post in threaded view
|

Re: Flink SQL解析问题

Jark
Administrator
我记得这个好像是个 bug,已经在 calcite 修复了。 你用的是哪个版本的 flink?

Best,
Jark

On Thu, 14 May 2020 at 15:30, Senior.Hu <[hidden email]> wrote:

> Hi All,
> &nbsp; 在用FlinkSqlParserImpl.FACTORY解析Flink DML SQL时,发现解析Join with Temporal
> Table语法,会自动加上LATERAL关键字,如下所示
> &nbsp; LEFT JOIN
> &nbsp; &nbsp; &nbsp; &nbsp; side_room FOR SYSTEM_TIME AS OF a1.proctime as
> a2
> &nbsp; &nbsp; ON
> &nbsp; &nbsp; &nbsp; &nbsp; a1.rowkey_room = a2.rowkey
> &nbsp; 解析后变成如下:
> &nbsp;&nbsp;LEFT JOIN LATERAL `side_room` FOR SYSTEM_TIME AS OF
> `a1`.`proctime` AS `a2` ON `a1`.`rowkey_room` = `a2`.`rowkey`
> &nbsp;&nbsp;
> &nbsp; 此SQL语法在Flink SQL中执行会报错如下:
> &nbsp; Caused by: org.apache.flink.table.api.SqlParserException: SQL parse
> failed. Encountered "`side_room`" at line 7, column 19.
> &nbsp; Was expecting one of:
> &nbsp; &nbsp; "TABLE" ...
> &nbsp; &nbsp; "(" ...
> &nbsp;&nbsp;
> &nbsp;我的SqlParser.Config类定义如下:
> &nbsp;private final SqlParser.Config config = SqlParser.configBuilder()
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> .setParserFactory(FlinkSqlParserImpl.FACTORY)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setQuoting(Quoting.BACK_TICK)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> .setUnquotedCasing(Casing.UNCHANGED)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
> .setQuotedCasing(Casing.UNCHANGED)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .setCaseSensitive(true)
> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .build();
> &nbsp;&nbsp;
> &nbsp; 不知道这个地方为什么会出现这种情况,或者是我这边使用方法不对?
Reply | Threaded
Open this post in threaded view
|

回复: Flink SQL解析问题

Senior.Hu
1.10




------------------&nbsp;原始邮件&nbsp;------------------
发件人:&nbsp;"Jark Wu"<[hidden email]&gt;;
发送时间:&nbsp;2020年5月17日(星期天) 中午11:42
收件人:&nbsp;"user-zh"<[hidden email]&gt;;

主题:&nbsp;Re: Flink SQL解析问题



我记得这个好像是个 bug,已经在 calcite 修复了。 你用的是哪个版本的 flink?

Best,
Jark

On Thu, 14 May 2020 at 15:30, Senior.Hu <[hidden email]&gt; wrote:

&gt; Hi All,
&gt; &amp;nbsp; 在用FlinkSqlParserImpl.FACTORY解析Flink DML SQL时,发现解析Join with Temporal
&gt; Table语法,会自动加上LATERAL关键字,如下所示
&gt; &amp;nbsp; LEFT JOIN
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; side_room FOR SYSTEM_TIME AS OF a1.proctime as
&gt; a2
&gt; &amp;nbsp; &amp;nbsp; ON
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a1.rowkey_room = a2.rowkey
&gt; &amp;nbsp; 解析后变成如下:
&gt; &amp;nbsp;&amp;nbsp;LEFT JOIN LATERAL `side_room` FOR SYSTEM_TIME AS OF
&gt; `a1`.`proctime` AS `a2` ON `a1`.`rowkey_room` = `a2`.`rowkey`
&gt; &amp;nbsp;&amp;nbsp;
&gt; &amp;nbsp; 此SQL语法在Flink SQL中执行会报错如下:
&gt; &amp;nbsp; Caused by: org.apache.flink.table.api.SqlParserException: SQL parse
&gt; failed. Encountered "`side_room`" at line 7, column 19.
&gt; &amp;nbsp; Was expecting one of:
&gt; &amp;nbsp; &amp;nbsp; "TABLE" ...
&gt; &amp;nbsp; &amp;nbsp; "(" ...
&gt; &amp;nbsp;&amp;nbsp;
&gt; &amp;nbsp;我的SqlParser.Config类定义如下:
&gt; &amp;nbsp;private final SqlParser.Config config = SqlParser.configBuilder()
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&gt; .setParserFactory(FlinkSqlParserImpl.FACTORY)
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .setQuoting(Quoting.BACK_TICK)
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&gt; .setUnquotedCasing(Casing.UNCHANGED)
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
&gt; .setQuotedCasing(Casing.UNCHANGED)
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .setCaseSensitive(true)
&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .build();
&gt; &amp;nbsp;&amp;nbsp;
&gt; &amp;nbsp; 不知道这个地方为什么会出现这种情况,或者是我这边使用方法不对?
Reply | Threaded
Open this post in threaded view
|

Re: Flink SQL解析问题

Jark
Administrator
Hi,

https://issues.apache.org/jira/browse/CALCITE-3603 这个是 Calcite 修复的链接,在
Calcite-1.22 版本中修复了。
Flink 是在1.11 版本中升级到了 Calcite-1.22:
https://issues.apache.org/jira/browse/FLINK-14338

所以可能你需要等待下 Flink 1.11, 或者可以拿 release-1.11 分支自己先编译一个。

Best,
Jark

On Mon, 18 May 2020 at 17:01, Senior.Hu <[hidden email]> wrote:

> 1.10
>
>
>
>
> ------------------&nbsp;原始邮件&nbsp;------------------
> 发件人:&nbsp;"Jark Wu"<[hidden email]&gt;;
> 发送时间:&nbsp;2020年5月17日(星期天) 中午11:42
> 收件人:&nbsp;"user-zh"<[hidden email]&gt;;
>
> 主题:&nbsp;Re: Flink SQL解析问题
>
>
>
> 我记得这个好像是个 bug,已经在 calcite 修复了。 你用的是哪个版本的 flink?
>
> Best,
> Jark
>
> On Thu, 14 May 2020 at 15:30, Senior.Hu <[hidden email]&gt; wrote:
>
> &gt; Hi All,
> &gt; &amp;nbsp; 在用FlinkSqlParserImpl.FACTORY解析Flink DML SQL时,发现解析Join with
> Temporal
> &gt; Table语法,会自动加上LATERAL关键字,如下所示
> &gt; &amp;nbsp; LEFT JOIN
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; side_room FOR SYSTEM_TIME
> AS OF a1.proctime as
> &gt; a2
> &gt; &amp;nbsp; &amp;nbsp; ON
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a1.rowkey_room = a2.rowkey
> &gt; &amp;nbsp; 解析后变成如下:
> &gt; &amp;nbsp;&amp;nbsp;LEFT JOIN LATERAL `side_room` FOR SYSTEM_TIME AS
> OF
> &gt; `a1`.`proctime` AS `a2` ON `a1`.`rowkey_room` = `a2`.`rowkey`
> &gt; &amp;nbsp;&amp;nbsp;
> &gt; &amp;nbsp; 此SQL语法在Flink SQL中执行会报错如下:
> &gt; &amp;nbsp; Caused by: org.apache.flink.table.api.SqlParserException:
> SQL parse
> &gt; failed. Encountered "`side_room`" at line 7, column 19.
> &gt; &amp;nbsp; Was expecting one of:
> &gt; &amp;nbsp; &amp;nbsp; "TABLE" ...
> &gt; &amp;nbsp; &amp;nbsp; "(" ...
> &gt; &amp;nbsp;&amp;nbsp;
> &gt; &amp;nbsp;我的SqlParser.Config类定义如下:
> &gt; &amp;nbsp;private final SqlParser.Config config =
> SqlParser.configBuilder()
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &gt; .setParserFactory(FlinkSqlParserImpl.FACTORY)
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> .setQuoting(Quoting.BACK_TICK)
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &gt; .setUnquotedCasing(Casing.UNCHANGED)
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> &gt; .setQuotedCasing(Casing.UNCHANGED)
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> .setCaseSensitive(true)
> &gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;
> .build();
> &gt; &amp;nbsp;&amp;nbsp;
> &gt; &amp;nbsp; 不知道这个地方为什么会出现这种情况,或者是我这边使用方法不对?