You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-zh@flink.apache.org by shougou <80...@qq.com> on 2021/03/05 01:59:01 UTC

Flink1.12 如何使用代码提交Batch的Sql

我们知道如果在1.12里使用Table API来提交Batch的作业,比如:
StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
env.setRuntimeMode(RuntimeExecutionMode.BATCH);

但是,如果提交Sql作业的话:
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
Table result = tableEnv.sqlQuery(...);
文档里也找不到如何使用StreamTableEnvironment 来跑Batch的SQL,又或者使用BatchTableEnvironment?

感谢各位提供思路!





--
Sent from: http://apache-flink.147419.n8.nabble.com/

Re: Flink1.12 如何使用代码提交Batch的Sql

Posted by shougou <80...@qq.com>.
感谢Qishang同学的回复!

我主要的目标是往一个运行的Flink集群上提交SQL,因为需要开窗写hive表,只能提交Batch的SQL。

如果是stream的,我是这么提交Sql,可以提交到Flink集群上:
final StreamExecutionEnvironment env = 
                
StreamExecutionEnvironment.createRemoteEnvironment("tkbd01", 8081);
        //StreamExecutionEnvironment bsEnv =
StreamExecutionEnvironment.getExecutionEnvironment();
EnvironmentSettings bsSettings = 
                       
EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build();
StreamTableEnvironment bsTableEnv = StreamTableEnvironment.create(env,
bsSettings);
//TableEnvironment bsTableEnv = TableEnvironment.create(bsSettings);

但是这个是*StreamExecutionEnvironment 没有办法执行BatchMode*
矛盾的地方在于 如果使用  TableEnvironment bsTableEnv =
TableEnvironment.create(bsSettings);  来执行Batch sql,又没有办法*通过final
StreamExecutionEnvironment env   来创建TableEnvironment*。





--
Sent from: http://apache-flink.147419.n8.nabble.com/

Re: Flink1.12 如何使用代码提交Batch的Sql

Posted by Qishang <zh...@gmail.com>.
Hi shougou.

你要找的是不是这个[1]

// ******************// BLINK BATCH QUERY// ******************import
org.apache.flink.table.api.EnvironmentSettings;import
org.apache.flink.table.api.TableEnvironment;
EnvironmentSettings bbSettings =
EnvironmentSettings.newInstance().useBlinkPlanner().inBatchMode().build();TableEnvironment
bbTableEnv = TableEnvironment.create(bbSettings);

[1]
https://ci.apache.org/projects/flink/flink-docs-release-1.12/dev/table/common.html#create-a-tableenvironment


shougou <80...@qq.com> 于2021年3月5日周五 上午9:59写道:

> 我们知道如果在1.12里使用Table API来提交Batch的作业,比如:
> StreamExecutionEnvironment env =
> StreamExecutionEnvironment.getExecutionEnvironment();
> env.setRuntimeMode(RuntimeExecutionMode.BATCH);
>
> 但是,如果提交Sql作业的话:
> StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env);
> Table result = tableEnv.sqlQuery(...);
> 文档里也找不到如何使用StreamTableEnvironment 来跑Batch的SQL,又或者使用BatchTableEnvironment?
>
> 感谢各位提供思路!
>
>
>
>
>
> --
> Sent from: http://apache-flink.147419.n8.nabble.com/
>