Zepl
Search…
Zepl Commands
Zepl exposes several built in functions from the Zeppelin context. These functions are accessible through a predefined variable, z. The zobject can be used by directly invoking its methods. The methods available in the z object are described below.

Dynamic Forms

With dynamic forms, you can enable notebook users to interact with your code without ever exposing them to it. To produce these form inputs, invoke the methods below:

Check Box

Python
Scala
PySpark
Function Definition: z.checkbox(string title, list[(value, display)] options, list default_selected): Return List
1
%python
2
​
3
options = [("apple","Apple"), ("banana","Banana"), ("orange","Orange")]
4
list = z.checkbox("fruit", options, ["apple", "orange"])
5
​
6
print(list)
Copied!
Function Definition: z.checkbox(String title, Seq((value, display))): Return Seq(Object)
1
%spark
2
val options = Seq(("apple","Apple"), ("banana","Banana"), ("orange","Orange"))
3
val list = z.checkbox("Fruit", options)
4
​
5
println(list)
Copied!
Function Definition: z.checkbox(string title, list[(value, display)] options, list default_selected): Return List
1
%pyspark
2
​
3
options = [("apple","Apple"), ("banana","Banana"), ("orange","Orange")]
4
list = z.checkbox("fruit", options, ["apple", "orange"])
5
​
6
print(list)
Copied!

Text Box

Python
Scala
Pyspark
Function Definition: z.textbox(string name, string value): Return string
1
%python
2
s = z.textbox("name", "sun")
3
​
4
print("Hello " + s)
Copied!
Function Definition: z.textbox(String name, String value): Return String
1
%spark
2
val s = z.textbox("name", "sun")
3
println("Hello " + s)
Copied!
Function Definition: z.textbox(string name, string value): Return string
1
%python
2
s = z.textbox("name", "sun")
3
​
4
print("Hello " + s)
Copied!
Python
Scala
PySpark
Function Definition: z.select(string label, list[(value, name)]): Return value
1
%python
2
day = z.select("day", [("1","mon"),
3
("2","tue"),
4
("3","wed"),
5
("4","thur"),
6
("5","fri"),
7
("6","sat"),
8
("7","sun")])
9
print("Hello " + day)
10
​
Copied!
Function Definition: z.select(String label, Seq(value, name)): Return value
1
%spark
2
val day = z.select("day", Seq(("1","mon"),
3
("2","tue"),
4
("3","wed"),
5
("4","thur"),
6
("5","fri"),
7
("6","sat"),
8
("7","sun")))
9
println("Hello " + day)
Copied!
Function Definition: z.select(string label, list[(value, name)]): Return value
1
%pyspark
2
day = z.select("day", [("1","mon"),
3
("2","tue"),
4
("3","wed"),
5
("4","thur"),
6
("5","fri"),
7
("6","sat"),
8
("7","sun")])
9
print("Hello " + day)
Copied!
​
In addition, variables can be added to SQL queries to allow the user to dynamically filter query results. This removes the need for users like data analysts to spend time making simple code or query updates.

​Open in Zepl​

Object Exchange

With the z object you can share data between the Spark, Python and R environments using the z.put() and z.get() methods. These methods can only take in primitive data types such as, String, Int, Boolean, Vector, and Seq. For example, you can put some objects using Scala in a Spark interpreter and read it from Python and vice versa.

PUT

Function Definition: z.put(String name, Object data)

GET

Function Definition: z.get(String name): Return Object
Example
Pass data from Spark to R and Python:
1
%spark
2
// String
3
val scala_str = "Hello from spark"
4
z.put("scala_str", scala_str)
5
​
6
// Integer
7
val scala_int = new Integer(42)
8
z.put("scala_int", scala_int)
9
​
10
// Vector
11
val scala_vec = Vector(1,2,3,4)
12
z.put("scala_vec", scala_vec)
Copied!
Print data in R and Python:
1
%r
2
#Prining Scala variables
3
z.get("scala_str")
4
z.get("scala_int")
5
z.get("scala_vec")
Copied!
1
%python
2
#Prining Scala variables
3
print(z.get("scala_str"))
4
print(z.get("scala_int"))
5
print(z.get("scala_vec"))
Copied!
This is not a supported method for passing DataFrame objects between languages. To do this, use Spark temporary tables and pass values between Scala and PySpark.

​

​
Last modified 1yr ago