Hi all, 在Spark中,可以通过调用Dataset的queryExecution.debug.codegen() 方法获得 Catalyst 产生的代码。 在Flink是否有类似的方法可以获得code gen的代码?
参考链接: https://medium.com/virtuslab/spark-sql-under-the-hood-part-i-26077f85ebf0*来自志愿者整理的flink邮件归档
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*来自志愿者整理的flink邮件归档
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。