Apache Zeppelin connection
Apache Zeppelin is a web-based notebook for interactive data analysis. With Zeppelin, you can create interactive, collaborative documents by using rich, pre-built language backends (or interpreters), such as Scala, Python, Spark SQL, and Hive. This topic describes how to connect Apache Zeppelin to AnalyticDB for PostgreSQL and visualize your data.
Prerequisites
You need an active AnalyticDB for PostgreSQL instance.
Procedure
-
Install Apache Zeppelin. For details, see the official Apache Zeppelin documentation.
-
Configure an interpreter.
-
Log on to Apache Zeppelin. In the upper-right corner, click your username and select Interpreter from the drop-down menu to open the interpreter configuration page.
-
In the upper-right corner of the page, click +Create to create a new interpreter.
Set the Interpreter group to JDBC. This guide uses jdbc-test as an example name.
NoteRecent Apache Zeppelin versions have deprecated the dedicated PostgreSQL interpreter and merged its functionality into the JDBC interpreter. Therefore, use the JDBC interpreter to connect to AnalyticDB for PostgreSQL.
-
After you set the Interpreter group to JDBC, configure the following parameters.
Parameter
Description
default.url
The JDBC URL. Use the format
jdbc:postgresql://{host}:{port}/{database}.-
host: The instance's network address. You can find this on the Basic Information page of your AnalyticDB for PostgreSQL instance, in the Database Connection Information section.
-
port: The port of the instance. You can go to the Basic Information page of AnalyticDB for PostgreSQL and obtain the instance port from the Database Connection Information section.
-
database: The name of the database.
default.user
The database username.
default.password
The password for the database username.
You can also configure other parameters on the page as needed. For more details, see the official Apache Zeppelin documentation.
-
-
Click Save at the bottom of the page to save the configuration.
-
-
Create a new notebook to query and analyze data.
-
In the top navigation bar, click Notebook and select Create new note.
-
Enter a name for the note and select the interpreter you created from the Default Interpreter list, for example, jdbc-test.
-
Click Create.
-
In the new notebook, write and run SQL statements to query and analyze your data.
When writing SQL, you must specify the interpreter at the beginning of each paragraph by adding its name, for example,
%jdbc-test. This directs Zeppelin to use that interpreter for the query. For example, after you run a paragraph containing%jdbc-testand an SQL statement likeSELECT * FROM my_table;, the status changes to FINISHED and the query results are displayed. By default, results appear in a table with columns such as id, name, and age. You can use the toolbar above the results to visualize the data as a bar chart, pie chart, area chart, line chart, or scatter plot.
-