Using Dynamic Input Forms in Notebooks

Qubole supports Apache Zeppelin’s dynamic input forms and also based on the language backend. You can run the paragraphs several time after you change the input values. You can create forms by:

Dynamic forms are supported on Spark notebooks. For more information about parameterized notebook API that uses these dynamic forms to populate parameter values, see Run a Notebook.

Using Form Templates

You can create a text-input form, select form, and a check box form using form templates. You can change the values in the input fields and rerun the paragraph as many times as required.

A simple form can be created as shown in this example.

../../../../_images/FormTemplate.png

A simple check box form can be created as shown in this example.

../../../../_images/CheckboxForm.png

For more information, see using form templates.

Using Programming Language

You can create a text input form, check box form using the scala (%spark) and Python (%pyspark) interpreters. As in using form templates, by using the programming language, you can also change the value of inputs and rerun the paragraphs as many times as required.

A simple form can be created as shown in this example.

../../../../_images/ProgramFormTemplate.png

A simple check box form can be created as shown in this example.

../../../../_images/ProgramCheckboxForm.png

For more information, see creating forms programmatically.

Example

The following example shows how to use z.bind() function to create universal variable with dynamic forms. You can run this sample code as a paragraph on the Notebooks page.

First Paragraph

%spark

z.angularBind("year",z.input("Year"))

Second Paragraph

%spark
z.show(sqlContext.sql("""
SELECT avg(depth) as avg_depth, max(depth) as max_depth, min(depth) as min_depth
FROM eq
WHERE year = """ + z.angular("year") + """
"""
))

Third Paragraph

%spark
z.show(sqlContext.sql("""
SELECT avg(lat) as avg_lat, avg(lon) as avg_lon
FROM eq
WHERE year = """ + z.angular("year") + """
"""
))

The following figure shows the sample paragraphs that use universal variables using Angular Bind.

../../../../_images/angular-bind.png