MaxCompute allows you to connect a MaxCompute project to Davinci. You can use various data visualization applications based on simple configurations on the Davinci UI. This topic describes how to use a MaxCompute Java Database Connectivity (JDBC) driver to connect Davinci to a MaxCompute project and analyze data in a visualized manner.
Background information
Davinci is an end-to-end data visualization solution for business personnel, data engineers, data analysts, and data scientists. You can analyze data based on simple configurations on the Davinci UI. You can also implement visualization features such as advanced interaction, industry analysis, pattern exploration, and social intelligence. For more information about Davinci, see Davinci.
Prerequisites
Make sure that the following conditions are met:
A MaxCompute project is created.
For more information about how to create a MaxCompute project, see Create a MaxCompute project.
The AccessKey pair of your Alibaba Cloud account that is used to access the MaxCompute project is obtained.
You can obtain the AccessKey pair on the AccessKey Pair page.
The JAR package of MaxCompute JDBC driver V3.0.1 or later is downloaded. This package includes the
jar-with-dependencies
package.In this topic, MaxCompute JDBC driver V3.2.9 is used.
Davinci is installed and configured.
For more information about how to install and configure Davinci, see Install and configure Davinci. You can also install Davinci by using Docker and mount the MaxCompute JDBC driver.
When you configure Davinci and mount the MaxCompute JDBC driver, make sure that MaxCompute is properly configured. For more information, see Precautions for configuring Davinci and mounting a driver.
Precautions for configuring Davinci and mounting a driver
When you configure Davinci and mount a driver, make sure that the following configurations are valid:
Mail configuration
# Configure information in the application.yml file in the config directory. mail: # The Simple Mail Transfer Protocol (SMTP) endpoint of a free email address. host: # The SMTP service port of a free email address. port: # The personal email address. username: # Not required. fromAddress: # An authorization code for the personal email address. This information is not the password of the email address. password: # The nickname of the email address, such as Davinci. nickname: # Retain default values for the following configuration items. properties: smtp: starttls: enable: true required: true auth: true mail: smtp: ssl: enable: true
Custom data source configuration
If you install Davinci based on the instruction provided in the official documentation of Davinci, open the custom data source configuration file datasource_driver.yml and configure the following information:
odps: name: odps desc: odps version: driver: com.aliyun.odps.jdbc.OdpsDriver keyword_prefix: keyword_suffix: alias_prefix: \` alias_suffix: \`
After the configuration is complete, manually copy the JAR package of the MaxCompute JDBC driver to the lib directory and restart Davinci.
If you use Docker to install Davinci, you must manually create a data source configuration file datasource_driver.yml and run the
vim docker-compose.yml
command to open the configuration file. The following sample code shows the configuration.volumes: - %Directory of odps-jdbc-x.x.x-jar-with-dependencies.jar%/odps-jdbc-x.x.x-jar-with-dependencies.jar:/opt/davinci/lib/odps-jdbc-x.x.x-jar-with-dependencies.jar - %Directory of datasource_driver.yml%/datasource_driver.yml:/opt/davinci/config/datasource_driver.yml
odps-jdbc-x.x.x-jar-with-dependencies.jar
is the name of the JAR package of the MaxCompute JDBC driver, such asodps-jdbc-3.2.9-jar-with-dependencies.jar
. After the configuration is complete, restart Davinci.
Step 1: Connect Davinci to MaxCompute
Davinci can be started only after it is installed and configured as expected. If Davinci fails to start, you must check the Davinci configuration information again. For more information, see Precautions for configuring Davinci and mounting a driver.
Start and log on to Davinci.
For more information about how to log on to Davinci, see Log on to Davinci.
On the Davinci service page, click Create in the upper-right corner to create a project and save the project.
Go to the project that you create. In the left-side navigation pane, click the
icon. On the page that appears, click the
icon. In the Add Source dialog box, configure the parameters. The following table describes the parameters.
Parameter
Description
Parameter
Description
Name
The name of the new data source. The name is used to distinguish the connections of different databases in the system.
Type
The driver that is used to access the MaxCompute project. Set the value to JDBC.
Database
The type of the destination database to which you want to connect. Set the value to odps.
Username
The AccessKey ID that is used to access the MaxCompute project.
You can obtain the AccessKey ID on the AccessKey Pair page.
Password
The AccessKey secret that corresponds to the AccessKey ID.
You can obtain the AccessKey secret on the AccessKey Pair page.
URL
The URL that is used to connect to the MaxCompute project. The format is
jdbc:odps:<Maxcompute_endpoint>?project=<Maxcompute_project_name>[&interactiveMode={true|false}]
. Delete theangle brackets (<>)
when you configure this parameter. Parameters in the format:<MaxCompute_endpoint>: required. The endpoint of MaxCompute. Configure this parameter based on the region where the MaxCompute project resides.
For more information about the endpoints of MaxCompute in different regions, see Endpoints.
<MaxCompute_project_name>: required. The name of the MaxCompute project.
This parameter specifies the name of your MaxCompute project instead of the DataWorks workspace to which the MaxCompute project corresponds. You can log on to the MaxCompute console, select the region where your MaxCompute project resides in the top navigation bar, and then view the name of the MaxCompute project on the Project management tab.
interactiveMode: optional. This parameter specifies whether to enable the MaxCompute Query Acceleration (MCQA) feature.
If you want to enable the MCQA feature, add
&interactiveMode=true
to the end of the URL. For more information about the MCQA feature, see Query acceleration.
Click Test. After the connection succeeds, click Save.
Step 2: Use Davinci to query and analyze data
You can use Davinci views to manage SQL templates, configure data models that are obtained after SQL statements are executed, and configure row and column permissions. Then, you can use widgets to further aggregate and group SQL results based on the data models provided by the views. You can encode the processed data in a visualized manner. You can perform the following operations. For more information, see Davinci help.
Query all existing tables
On the data view page, click the
icon in the upper-right corner to open the SQL editor and select the data source that you create to view all tables.
Query a table schema
On the data view page, click the
icon in the upper-right corner to go to the SQL editor. Select the data source that you create, write and run an SQL script, and then click Next to view the table schema information.
Query table data
On the data view page, click the
icon in the upper-right corner to go to the SQL editor. Select the data source that you create, write an SQL script, and then click Run to view table data.
Visualize analysis data
On the Visualization Components page, click the
icon in the upper-right corner to go to the chart editor. Select a chart type and configure properties. Then, you can analyze data based on your business requirements.