-1

I want to fill a Checkbox in spark with the distinct values of a column, because in the next step this shall be my filter options.

My data Looks like this:

df:

root
 |-- KW: integer (nullable = true)
 |-- grund: long (nullable = true)
 |-- text_rotschaltung: string (nullable = true)
 |-- Anzahl: long (nullable = false)

ColumnFilter:

root
 |-- grund: long (nullable = true)

The column "grund" is an identifier for the reason from failures. And in my report the user shall be filter interactively which reasons he wants to see.

Actually I have this code part:

...

    val df = rdd1.toDF()
    var ColumnFilter = df.orderBy("grund").select("grund").distinct



println("Hello "+z.checkbox("The reasons:", ColumnFilter).mkString(" and "))

With this code I get the error:

error: type mismatch;
 found   : org.apache.spark.sql.DataFrame
 required: Iterable[(Object, String)]
println("Hello "+z.checkbox("The reasons", ColumnFilter).mkString(" and "))

How can I convert a DataFrame to Iterable or which other Options have I to fill the Checkbox?

Thank you very much.

DaShI
  • 61
  • 1
  • 5
  • how does youe `z.checkbox` method look like? – philantrovert Sep 18 '17 at 08:22
  • In this Moment I haven´t got a method. So I want to fill it like in this example: val options = Seq(("apple","Apple"), ("banana","Banana"), ("orange","Orange")) println("Hello "+z.checkbox("fruit", options).mkString(" and ")) (https://zeppelin.apache.org/docs/latest/manual/dynamicform.html) With the difference, that I use the column. – DaShI Sep 18 '17 at 08:28
  • Then I think you should update your question with your current input dataframe, how you want your output to look like and what have you tried till now. – philantrovert Sep 18 '17 at 08:29

1 Answers1

0

How can I convert a DataFrame to Iterable

Use collect to get the data back (from inside of DataFrame).

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420