Re: flink-sql-gateway如何使用flink自定义的udf

2021-01-27 Thread Sebastian Liu
1. 确保udf jar 在gateway jvm的classpath中
2. 配置:
https://github.com/ververica/flink-sql-gateway/blob/master/conf/sql-gateway-defaults.yaml#L87

阿华田  于2021年1月27日周三 下午3:26写道:

> 各位大佬,Flink-sql-gateway 提交flink sql任务 ,如何使用flink自定义的udf
>
>
> | |
> 阿华田
> |
> |
> a15733178...@163.com
> |
> 签名由网易邮箱大师定制
>
>

-- 

*With kind regards
--------
Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: sql编译代码时超过64kb导致编译失败

2021-01-27 Thread Sebastian Liu
e2(UnitCompiler.java:432)
> at
> org.codehaus.janino.UnitCompiler.access$400(UnitCompiler.java:215)
> at
>
> org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:411)
> at
>
> org.codehaus.janino.UnitCompiler$2.visitPackageMemberClassDeclaration(UnitCompiler.java:406)
> at
>
> org.codehaus.janino.Java$PackageMemberClassDeclaration.accept(Java.java:1414)
> at org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:406)
> at
> org.codehaus.janino.UnitCompiler.compileUnit(UnitCompiler.java:378)
> ... 51 more
>
>
>
> --
> Sent from: http://apache-flink.147419.n8.nabble.com/
>


-- 

*With kind regards

Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: flink-sql-gateway相关问题

2021-01-26 Thread Sebastian Liu
看报错提示,应该是没有指定正确HADOOP_HOME env? 如果用flink client提交,也是需要这个env的

zilong xiao  于2021年1月27日周三 上午10:17写道:

> 感谢您的回答,我在flink-conf.yaml里指定"execution.target: yarn-pre-job"后,尝试用rest
> api生成session id时会遇到异常,不清楚是为何,可否帮忙看下
>
> flink version: 1.11.3
> execution.target: yarn-pre-job
> rest api请求路径和参数:
> http://localhost:8083/v1/sessions
> {
> "planner": "blink",
> "execution_type": "streaming"
>}
>
> 异常信息:Caused by: java.lang.IllegalStateException: No ClusterClientFactory
> found. If you were targeting a Yarn cluster, please make sure to export the
> HADOOP_CLASSPATH environment variable or have hadoop in your classpath. For
> more information refer to the "Deployment & Operations" section of the
> official Apache Flink documentation.
>
> Sebastian Liu  于2021年1月27日周三 上午1:01写道:
>
> > sql gateway 提交job方式和flink client类似主要取决于flink-conf中的execution.config 配置,
> > 对per job模式on yarn, 对应的配置是“yarn-per-job”,
> >
> >
> 这样加载的PipelineExecutor会控制为:YarnJobClusterExecutorFactory,具备向Yarn提交job的能力,这和使用flink
> > client
> > 提交job最终是一个调用路径,余下在flink-conf中添加上yarn相关配置我理解就可以了。
> > org.apache.flink.yarn.configuration.YarnConfigOptions
> >
> > zilong xiao  于2021年1月26日周二 下午4:00写道:
> >
> > > 请问有关于flink-sql-gateway rest api以pre job模式提交作业到yarn集群的文档吗?
> > >
> >
> >
> > --
> >
> > *With kind regards
> > 
> > Sebastian Liu 刘洋
> > Institute of Computing Technology, Chinese Academy of Science
> > Mobile\WeChat: +86—15201613655
> > E-mail: liuyang0...@gmail.com 
> > QQ: 3239559*
> >
>


-- 

*With kind regards

Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: flink-sql-gateway支持远程吗

2021-01-26 Thread Sebastian Liu
Hi zilong,

sql gateway复用了很多底层API,其提交方式很多复用了flink client的逻辑。
针对提交模式,主要是看flink-conf.yaml中的的execution.config 配置, 关于这个配置
可以参考:org.apache.flink.configuration.DeploymentOptions#TARGET
如果是yarn-per-job, 需要配置为:“yarn-per-job”, 同时也依赖flink-conf.yaml中其他yarn的相关配置:
可参考:org.apache.flink.yarn.configuration.YarnConfigOptions

总结一下就是:
1. sql gateway找到正确的flink-conf.yaml, 取决于FLINK_HOME or FLINK_CONF_DIR.
2. 根据execution.config选择对应executor,然后不同模式依赖于flink-conf对应的提交相关配置


zilong xiao  于2021年1月27日周三 上午10:19写道:

> 如果是yarn-pre-job,是如何提交到yarn集群的呢,跟host * rest port应该没关系了吧?
>
> Sebastian Liu  于2021年1月27日周三 上午12:48写道:
>
> > flink-sql-gateway在提交job时,会根据SPI加载executor,然后推断是local mode还是remote mode,
> > 在remote mode下,根据FLINK_HOME 目录下config.sh推断的FLINK_CONF_DIR
> 寻找flink-conf.yaml,
> > 其中的host, rest port决定了提交的远端集群
> >
> > 罗显宴 <15927482...@163.com> 于2021年1月23日周六 上午11:19写道:
> >
> > >
> > >
> >
> 大佬们,我试过flinksql-client和flink-sql-gateway发现都是把代码提交到本地集群运行,好像不能提交到指定远程集群上执行任务,请问大佬们,怎么提交代码到远程集群运行
> > >
> > >
> > > | |
> > > 15927482803
> > > |
> > > |
> > > 邮箱:15927482...@163.com
> > > |
> > >
> > > 签名由 网易邮箱大师 定制
> >
> >
> >
> > --
> >
> > *With kind regards
> > 
> > Sebastian Liu 刘洋
> > Institute of Computing Technology, Chinese Academy of Science
> > Mobile\WeChat: +86—15201613655
> > E-mail: liuyang0...@gmail.com 
> > QQ: 3239559*
> >
>


-- 

*With kind regards

Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: flink-sql-gateway相关问题

2021-01-26 Thread Sebastian Liu
sql gateway 提交job方式和flink client类似主要取决于flink-conf中的execution.config 配置,
对per job模式on yarn, 对应的配置是“yarn-per-job”,
这样加载的PipelineExecutor会控制为:YarnJobClusterExecutorFactory,具备向Yarn提交job的能力,这和使用flink
client
提交job最终是一个调用路径,余下在flink-conf中添加上yarn相关配置我理解就可以了。
org.apache.flink.yarn.configuration.YarnConfigOptions

zilong xiao  于2021年1月26日周二 下午4:00写道:

> 请问有关于flink-sql-gateway rest api以pre job模式提交作业到yarn集群的文档吗?
>


-- 

*With kind regards
----
Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: flink-sql-gateway支持远程吗

2021-01-26 Thread Sebastian Liu
flink-sql-gateway在提交job时,会根据SPI加载executor,然后推断是local mode还是remote mode,
在remote mode下,根据FLINK_HOME 目录下config.sh推断的FLINK_CONF_DIR 寻找flink-conf.yaml,
其中的host, rest port决定了提交的远端集群

罗显宴 <15927482...@163.com> 于2021年1月23日周六 上午11:19写道:

>
> 大佬们,我试过flinksql-client和flink-sql-gateway发现都是把代码提交到本地集群运行,好像不能提交到指定远程集群上执行任务,请问大佬们,怎么提交代码到远程集群运行
>
>
> | |
> 15927482803
> |
> |
> 邮箱:15927482...@163.com
> |
>
> 签名由 网易邮箱大师 定制



-- 

*With kind regards
--------
Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: Using double quotes for SQL identifiers

2021-01-26 Thread Sebastian Liu
Hi Gyula,

AFAIK, except the sql-dialect, table API does not expose any parser related
configuration to the user.
But we still can change the config of quoting identifiers in parser with
some code changing.
You can reference this test class:
org.apache.flink.sql.parser.FlinkDDLDataTypeTest.TestFactory.


Gyula Fóra  于2021年1月26日周二 下午8:42写道:

> Hi All!
>
> Is it possible in any way to configure the Table environments to allow
> double quotes (") to be used for identifiers instead of backticks (`).
>
> Thank you!
> Gyula
>


-- 

*With kind regards
--------
Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: SQL作业的提交方式

2021-01-07 Thread Sebastian Liu
可以尝试一下:https://github.com/ververica/flink-sql-gateway

如果有相关的需求,可以提issue

jiangjiguang719  于2021年1月7日周四 下午8:34写道:

> 目前我司的SQL作业的提交 还是使用的 Jark 老师的 flink-sql-submit 项目,想问下:
> 1、有没有更好的SQL作业的提交方式?
> 2、既然flink1.12 已经实现批流一体,要实现即席查询怎么提交SQL呢?
> 3、SQL Client Gateway 社区大概啥时候发布?能够生产可用?



-- 

*With kind regards
----
Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: Flink SQL 如何保证多个sql 语句按顺序执行

2021-01-06 Thread Sebastian Liu
tableEnv.executeSql
会返回TableResult,可以从中获取JobClient,检查JobStatus,在Future中CallBack
写逻辑执行后续sql。不知道是否满足你的需求?

Jacob <17691150...@163.com> 于2021年1月6日周三 下午2:13写道:

> Dear All,在Flink SQL
>
> job中,如果有多个sql语句,需要按顺序执行,即下一个sql的执行依赖上一个sql的执行结果。由于tableEnv.executeSql(sql)是*异步*提交的,那么如何保证多个sql是*顺序执行*?eg:在一个main函数中,有如下代码:String
> sql1 = "";tableEnv.executeSql(sql1 );String sql2 =
> "";tableEnv.executeSql(sql2 );问题:如何保证sql1先执行完成,再执行sql2
>
>
>
> -
> Thanks!
> Jacob
> --
> Sent from: http://apache-flink.147419.n8.nabble.com/



-- 

*With kind regards
--------
Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: FlinkSQL 下推的值类型与字段类型不对应

2021-01-04 Thread Sebastian Liu
Hi automths,

RexNode中的Literal type,在calcite convert to relNode的过程中,以col1 > 10为例,
10从calcite parse出来首先是SqlNumericLiteral, 其中类型会是Decimal(prec: 2, scale: 0).
在创建其对应的RelDataType时,如果其值域在Interger.MIN ~ Interger.Max之间,那就是Interger type。
如果不在就是decimal, 这里没有类似Hive的auto cast功能,而是calcite进行了隐式类型转换。
这里具体隐式转换的规则可以参考:
https://calcite.apache.org/docs/reference.html#implicit-type-conversion

对于Function中,参数的类型,Flink也有一套规则进行推导。

select * from shortRow1 where col1 > CAST(10 AS SMALLINT) and col1 <=
CAST(15 AS SMALLINT) 可以保证
在applyPredicates时看到的expression中,literal是预期的type,但不是特别通用,建议在相关connector中实现
一个TypeVisitor, 把literal转成预期的type。

Just my thoughts

automths  于2021年1月4日周一 上午9:36写道:

>
>
> 谢谢你的回答。
>
> 但是我的col1,col2就已经是SMALLINT类型的了,我的问题是where条件中值下推过程中是Integer类型的,我希望值也是SMALLINT的。
>
>
>
> 祝好!
> | |
> automths
> |
> |
> autom...@163.com
> |
> 在2020年12月31日 18:17,whirly 写道:
> Hi.
>
> 查询语句中可以使用 cast 内置函数将值强制转换为指定的类型,如 select CAST(A.`col1` AS SMALLINT) as
> col1 from table
>
>
> 参考:
>
> https://ci.apache.org/projects/flink/flink-docs-release-1.12/dev/table/functions/systemFunctions.html#type-conversion-functions
>
> https://ci.apache.org/projects/flink/flink-docs-release-1.12/dev/table/types.html#data-types
>
>
>
>
> best 2021.
>
>
> 在 2020-12-31 17:13:20,"automths"  写道:
> Hi:
> 我自定义connect并实现了FilterableTableSource接口,可是发现flink planner 下推的Filter中,
> Literal类型与字段类型不匹配。
> 比如:下面的SQL:
> select * from shortRow1 where key in (1, 2, 3) and col1 > 10 and col1 <= 15
> 其中DDL定义时, key、col1、col1都是SMALLINT类型
> 在下推的Filter中, GreaterThan中的Literal是Integer类型,这样是合理的吗?或者我的查询语句中要做什么处理?
>
>
> 祝好!
> | |
> automths
> |
> |
> autom...@163.com
> |
>
>

-- 

*With kind regards

Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: FlinkSQL是否支持设置窗口trigger实现continuious trigger呢

2020-12-30 Thread Sebastian Liu
table.exec.emit.early-fire.delay 是一个duration type的configuration,不写单位会apply失败

fan_future  于2020年12月30日周三 下午4:00写道:

> 这两个参数
> table.exec.emit.early-fire.enabled
> table.exec.emit.early-fire.delay
> 是怎么设置的??
>
> EnvironmentSettings build =
>
> EnvironmentSettings.newInstance().useBlinkPlanner().inStreamingMode().build();
> TableEnvironment tEnv = TableEnvironment.create(build);
>
> Configuration tableConfig = tEnv.getConfig().getConfiguration();
> tableConfig.setString("table.exec.emit.early-fire.enabled","true");
> tableConfig.setString("table.exec.emit.early-fire.delay","6");
> 我这样处理后就报错
>
>
>
> --
> Sent from: http://apache-flink.147419.n8.nabble.com/
>


-- 

*With kind regards

Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: flink 1.12.0 + hive 3.1.2 报错 java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument

2020-12-30 Thread Sebastian Liu
Hi Jianqiang,

看不到email中的截图。但从你的描述中看,似乎是shade jar的问题,Flink SQL
client启动的时候会自动使用FLINK_HOME/bin/config.sh中的constructFlinkClassPath,
并append到当前SQL client JVM的CC_CLASSPATH中。所以理论上不需要向Flink
lib目录cp其他jar,当然如果有特殊依赖jar,还是需要保证在CLASSPATH中的,
但使用“--jar”或者“--library”来传递这些似乎是更好的选择,这两个参数会把jar当做job的user
jar随JobGraph一起上传至JM。

flink-dist这个fat jar中应该已经有guava18.

Zeng, Jianqiang Zack  于2020年12月30日周三 下午5:04写道:

>
>
>
>
>
>
>
>
>
>
>
>
> Best Regards!
>
> Have a good day!
>
>
>
>
> *Zack Zeng *Associate Manager, Business Analyst
> Boston Scientific
> China Information Services
> jianqiang.z...@bsci.com
> (+86)21-61417831
> #763 Mengzi Road, Shanghai, China
> www.bostonscientific.com
>
> [image: bsc]
>
>
>
>
>
> *From:* Zeng, Jianqiang Zack
> *Sent:* Wednesday, December 30, 2020 4:42 PM
> *To:* user-zh@flink.apache.org
> *Subject:* flink 1.12.0 + hive 3.1.2 报错 java.lang.NoSuchMethodError:
> com.google.common.base.Preconditions.checkArgument
>
>
>
> 使用官网的Flink 1.12.0安装,已经正常启动,JPS可看到相关进程,WEBUI也正常启用,配置连接Hive 3.1.2,并将相关的JAR
> 包放入了flink下面的lib文件夹当中,但启动sql-client报错,搜索定位说是guava的问题,可是我guava的包是直接软链接到hive
> 下面的guava包,和hadoop也是共用同一个包,是哪里配置还有问题吗?相关截图如下,谢谢!
>
>
>
> JPS截图
>
>
>
> WebUI截图
>
>
>
> Flink/Lib 截图
>
>
>
> Sql-client截图
>
>
>
> *Sql-client启动报错截图*
>
>
>
> Hive正常启动截图
>
>
>
>
>
> Best Regards!
>
> Have a good day!
>
>
>
>
> *Zack Zeng *Associate Manager, Business Analyst
> Boston Scientific
> China Information Services
> jianqiang.z...@bsci.com
> (+86)21-61417831
> #763 Mengzi Road, Shanghai, China
> www.bostonscientific.com
>
> [image: bsc]
>
>
>
>
>


-- 

*With kind regards

Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*


Re: In the future,the community plans to extend its functionality by providing a REST-based SQL

2020-08-06 Thread Sebastian Liu
目前社区的flink-sql-client module的确只支持embedded
mode,目前一个client对应一个session以及executor来提交管理sql job,
session相关代码在module的gateway目录下。这块的方向应该是会将gateway 发展成一个独立的restful web
service(任务网关), 本质是一个session manager, serve多个client的sql statement请求.
从我的理解看,client的gateway mode,应该是会先启动内置的gateway service,然后client向gateway提交请求。
Reference:
Sql gateway: https://github.com/ververica/flink-sql-gateway
jdbc driver: https://github.com/ververica/flink-jdbc-driver  (jdbc <-> rest
http request)

air23  于2020年8月6日周四 下午3:19写道:

> Limitations & Future
> The current SQL Client only supports embedded mode. In the future, the
> community plans to extend its functionality by providing a REST-based SQL
> Client Gateway, see more in FLIP-24 and FLIP-91.
>
>
>
>
> 你好 在官方文档上看到了。请问这个还在计划中。是一种rest sql web客户端吗?



-- 

*With kind regards
--------
Sebastian Liu 刘洋
Institute of Computing Technology, Chinese Academy of Science
Mobile\WeChat: +86—15201613655
E-mail: liuyang0...@gmail.com 
QQ: 3239559*