How to write Flink var contents to the screen in Zeppelin?

I am trying to run the following simple commands in Apache Zeppelin.

%flink

var rabbit = env.fromElements(
"ARTHUR:  What, behind the rabbit?",
"TIM:  It is the rabbit!", 
"ARTHUR:  You silly sod!  You got us all worked up!",
"TIM:  Well, that no ordinary rabbit.  That the most foul, cruel, and bad-tempered rodent you ever set eyes on.",
"ROBIN:  You tit!  I soiled my armor I was so scared!", 
"TIM:  Look, that rabbit got a vicious streak a mile wide, it a killer!")

var counts = rabbit.flatMap { _.toLowerCase.split("\\W+")}.map{ (_,1)}.groupBy(0).sum(1) 

counts.print()

I am trying to print the results in a notebook. But, unfortunately, I get only the following result.

rabbit: org.apache.flink.api.scala.DataSet[String] = org.apache.flink.api.scala.DataSet@37fdb65c
counts: org.apache.flink.api.scala.AggregateDataSet[(String, Int)] = org.apache.flink.api.scala.AggregateDataSet@1efc7158
res103: org.apache.flink.api.java.operators.DataSink[(String, Int)] = DataSink '<unnamed>' (Print to System.out)

How can I spill the contents of counters on notepad in Zeppelin?

+4
source share
2 answers

Apache Zeppelin Apache Flink. Zeppelin Console. , Flink System.out, counts.print(). , bzz , , Console.

JIRA [1] [2], , counts.print().

+4

Zeppelin:

%flink
counts.collect().foreach(println(_))

//or one might prefer
//counts.collect foreach println 

:

(a,3)
(all,1)
(and,1)
(armor,1)
...
+5

Source: https://habr.com/ru/post/1605968/


All Articles