Scala
Last updated
Was this helpful?
Last updated
Was this helpful?
Scala is the default language of Flink on Zeppelin(%flink
), and it is also the entry point of Flink interpreter. Underneath Flink Interpreter will create scala shell which would create several variables, including ExecutionEnvironment,StreamExecutionEnvironment and so on. So don't create these Flink environment variables again, otherwise you might hit weird issues. The scala code you write in Zeppelin will be submitted to this scala shell. Here are the builtin variables created in flink scala shell.
senv
(StreamExecutionEnvironment),
benv
(ExecutionEnvironment)
stenv
(StreamTableEnvironment for blink planner)
btenv
(BatchTableEnvironment for blink planner)
stenv_2
(StreamTableEnvironment for flink planner)
btenv_2
(BatchTableEnvironment for flink planner)
z
(ZeppelinContext)
There’re 2 sql planners supported by flink’s table api: flink
& blink
.
If you want to use DataSet api, and convert it to flink table then please use flink planner (btenv_2
and stenv_2
).
In other cases, we would always recommend you to use blink planner (btenv
and stenv
). This is also what flink batch/streaming sql interpreter use underneath (%flink.bsql
& %flink.ssql
)
Check this for the details about these 2 planners.
You can write whatever flink scala code in Zeppelin. e.g. In the following example, we write a classical streaming wordcount job and print the result.
Besides that Zeppelin also enhance the scala shell with several user-friendly features.
You can type tab to get code completion.
ZeppelinContext (z
) provides several advanced features for you, e.g. you can use z.show
to display DataSet, Batch Table, Streaming Table
Join Zeppelin community to discuss with others