[jira] [Commented] (FLINK-25337) Check whether the target table is valid when SqlToOperationConverter.convertSqlInsert

2021-12-22 Thread vim-wang (Jira)


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

vim-wang commented on FLINK-25337:
--

[~wenlong.lwl], ok, thanks.

> Check whether the target table is valid when 
> SqlToOperationConverter.convertSqlInsert
> -
>
> Key: FLINK-25337
> URL: https://issues.apache.org/jira/browse/FLINK-25337
> Project: Flink
>  Issue Type: Improvement
>  Components: Table SQL / Planner
>Affects Versions: 1.14.0
>Reporter: vim-wang
>Priority: Major
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> when I execute insert sql like "insert into t1 select ...", 
> If the t1 is not defined,sql will not throw an exception after 
> SqlToOperationConverter.convertSqlInsert(), I think this is unreasonable, why 
> not use catalogManager to check whether the target table is valid?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (FLINK-25337) Check whether the target table is valid when SqlToOperationConverter.convertSqlInsert

2021-12-20 Thread Wenlong Lyu (Jira)


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

Wenlong Lyu commented on FLINK-25337:
-

Regarding sql validation,I think it is necessary to go through all steps of 
optimization the same as what you are doing now, validation in sql operation 
converter can not ensure that the sql is ok.

> Check whether the target table is valid when 
> SqlToOperationConverter.convertSqlInsert
> -
>
> Key: FLINK-25337
> URL: https://issues.apache.org/jira/browse/FLINK-25337
> Project: Flink
>  Issue Type: Improvement
>  Components: Table SQL / Planner
>Affects Versions: 1.14.0
>Reporter: vim-wang
>Priority: Major
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> when I execute insert sql like "insert into t1 select ...", 
> If the t1 is not defined,sql will not throw an exception after 
> SqlToOperationConverter.convertSqlInsert(), I think this is unreasonable, why 
> not use catalogManager to check whether the target table is valid?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (FLINK-25337) Check whether the target table is valid when SqlToOperationConverter.convertSqlInsert

2021-12-20 Thread Wenlong Lyu (Jira)


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

Wenlong Lyu commented on FLINK-25337:
-

hi,[~vim-wang] I think it would be better if you could post the case in 
English, it can help others in the community  understand and help you.

> Check whether the target table is valid when 
> SqlToOperationConverter.convertSqlInsert
> -
>
> Key: FLINK-25337
> URL: https://issues.apache.org/jira/browse/FLINK-25337
> Project: Flink
>  Issue Type: Improvement
>  Components: Table SQL / Planner
>Affects Versions: 1.14.0
>Reporter: vim-wang
>Priority: Major
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> when I execute insert sql like "insert into t1 select ...", 
> If the t1 is not defined,sql will not throw an exception after 
> SqlToOperationConverter.convertSqlInsert(), I think this is unreasonable, why 
> not use catalogManager to check whether the target table is valid?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (FLINK-25337) Check whether the target table is valid when SqlToOperationConverter.convertSqlInsert

2021-12-16 Thread vim-wang (Jira)


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

vim-wang commented on FLINK-25337:
--

英文不好,我用中文描述一下哈。

是想实现对一段sql做语法检测的功能,比如下面这段sql:

CREATE TABLE datagen (
  f1 BIGINT,
  f2 STRING
) WITH (
  'connector' = 'datagen',
  'rows-per-second' = '1'
);
CREATE TABLE print_table (
  f1 BIGINT,
  f2 STRING
) WITH (
  'connector' = 'print'
);
INSERT INTO print_table
SELECT 
  f1,
  f2
FROM datagen;

 

原本的实现方式是:

SqlParser sqlParser = SqlParser.create(sqls, sqlparserConfig); //sqls就是指上面那段sql
List sqlNodeList = sqlParser.parseStmtList().getList();

for (SqlNode sqlNode : sqlNodeList) {
    Operation operation = 
SqlToOperationConverter.convert(planner.createFlinkPlanner(),catalogManager, 
sqlNode).get();

}

 

这样做就存在之前描述中的问题,INSERT INTO 
print_table,print_table写成任何值SqlToOperationConverter.convert都不会报异常。所以我后来把operation也做了处理,比如modifyOperations调用planner.translate(modifyOperations),这样功能也能实现,但多了不少代码。

想问问针对这个场景,有便捷的实现方式吗?希望大佬指点。

> Check whether the target table is valid when 
> SqlToOperationConverter.convertSqlInsert
> -
>
> Key: FLINK-25337
> URL: https://issues.apache.org/jira/browse/FLINK-25337
> Project: Flink
>  Issue Type: Improvement
>  Components: Table SQL / Planner
>Affects Versions: 1.14.0
>Reporter: vim-wang
>Priority: Major
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> when I execute insert sql like "insert into t1 select ...", 
> If the t1 is not defined,sql will not throw an exception after 
> SqlToOperationConverter.convertSqlInsert(), I think this is unreasonable, why 
> not use catalogManager to check whether the target table is valid?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (FLINK-25337) Check whether the target table is valid when SqlToOperationConverter.convertSqlInsert

2021-12-16 Thread Wenlong Lyu (Jira)


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

Wenlong Lyu commented on FLINK-25337:
-

hi, [~vim-wang], I think it is because we need to check not only the table is 
existed, but also the schema should be matched and query is valid, etc, it may 
be better to put all check together. 
Do you have any actual problem on the check? IMO, the failure check will soon 
come up after convertSqlInsert.  If you could post your case, others in 
community could understand your problem better.

> Check whether the target table is valid when 
> SqlToOperationConverter.convertSqlInsert
> -
>
> Key: FLINK-25337
> URL: https://issues.apache.org/jira/browse/FLINK-25337
> Project: Flink
>  Issue Type: Improvement
>  Components: Table SQL / Planner
>Affects Versions: 1.14.0
>Reporter: vim-wang
>Priority: Major
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> when I execute insert sql like "insert into t1 select ...", 
> If the t1 is not defined,sql will not throw an exception after 
> SqlToOperationConverter.convertSqlInsert(), I think this is unreasonable, why 
> not use catalogManager to check whether the target table is valid?



--
This message was sent by Atlassian Jira
(v8.20.1#820001)