Apache Flink 中文用户邮件列表
Search
everywhere
only in this topic
Advanced Search
如何获取Flink table api/sql code gen 代码
Classic
List
Threaded
♦
♦
Locked
2 messages
Vincent Cai
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
如何获取Flink table api/sql code gen 代码
Hi all,
在Spark中,可以通过调用Dataset的queryExecution.debug.codegen() 方法获得 Catalyst 产生的代码。
在Flink是否有类似的方法可以获得code gen的代码?
参考链接:
https://medium.com/virtuslab/spark-sql-under-the-hood-part-i-26077f85ebf0
Regards
Vincent Cai
Zhenghua Gao
Reply
|
Threaded
Open this post in threaded view
♦
♦
|
Re: 如何获取Flink table api/sql code gen 代码
Currently Flink DO NOT provides a direct way to get code gen code. But
there are indirect ways to try.
1) debug in IDE
Flink use Janino to compile all code gen code, and there is a single entry
point [1]
<
https://github.com/apache/flink/blob/master/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/generated/CompileUtils.java
>
for
Blink planner, [2]
<
https://github.com/apache/flink/blob/master/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/codegen/Compiler.scala
>
for
old planner, you can set breakpoint there and get the code.
2) enable debug logging
Blink planner logging code in CompileUtils, and old planner logging code in
subclass of Compiler
3) use Janino options
Janino caches code in tmp directory, and you can enable these options[3]
<
https://github.com/janino-compiler/janino/blob/master/janino/src/main/java/org/codehaus/janino/Scanner.java#L71
>.
Note: org.codehaus.janino.source_debugging.keep is not supported in current
Janino version, which means this method can only be used to debug in
IDE(need breakpoint to keep source code)
[1]
https://github.com/apache/flink/blob/master/flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/generated/CompileUtils.java
[2]
https://github.com/apache/flink/blob/master/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/codegen/Compiler.scala
[3]
https://github.com/janino-compiler/janino/blob/master/janino/src/main/java/org/codehaus/janino/Scanner.java#L71
*Best Regards,*
*Zhenghua Gao*
On Wed, Aug 7, 2019 at 12:02 AM Vincent Cai <
[hidden email]
> wrote:
> Hi all,
> 在Spark中,可以通过调用Dataset的queryExecution.debug.codegen() 方法获得 Catalyst 产生的代码。
> 在Flink是否有类似的方法可以获得code gen的代码?
>
>
> 参考链接:
>
https://medium.com/virtuslab/spark-sql-under-the-hood-part-i-26077f85ebf0
>
>
> Regards
> Vincent Cai
Free forum by Nabble
Edit this page