Connect DataGrip to MaxCompute

更新时间:
复制 MD 格式

This topic describes how to connect DataGrip to a MaxCompute project using the MaxCompute JDBC driver.

Background

DataGrip, a database management environment for developers, simplifies database querying, creation, and management. It supports local, server-based, and cloud databases. For more information, see DataGrip.

Prerequisites

Make sure you meet the following requirements:

  • You have created a MaxCompute project.

    For more information, see Create a MaxCompute project.

  • You have an AccessKey ID and AccessKey Secret with permissions to access the MaxCompute project.

    Go to the AccessKey Management page to obtain an AccessKey ID and AccessKey Secret.

  • You have downloaded the MaxCompute JDBC driver JAR package with all dependencies (jar-with-dependencies).

    Download the driver by clicking odps-jdbc-3.9.0.jar, or get the latest version from GitHub or the Maven repository. This topic uses the MaxCompute JDBC driver v3.9.0 as an example.

  • You have downloaded and installed DataGrip.

    For more information, see Install DataGrip.

    This topic uses DataGrip 2024.3.3 as an example.

Procedure

To connect DataGrip to MaxCompute, follow these steps:

  1. Step 1: Add a driver and configure a data source

    Add the MaxCompute JDBC driver to DataGrip and configure the connection parameters for your MaxCompute project.

  2. Step 2: Use DataGrip to manage the MaxCompute project

    Use the created connection in DataGrip to manage your MaxCompute project.

Step 1: Configure driver and data source

  1. Start DataGrip.

  2. From the main menuimage, select File > Create > Project.

  3. In the New Project dialog box, enter a project name, such as MaxCompute_test.

  4. In the new project window, click Createimage > Driver in the upper-left corner.

  5. In the Data Sources and Drivers dialog box, go to the Drivers tab. Click the image icon and select User Driver. Name the driver, for example, MaxCompute.

  6. In the Driver Files section, click the image icon and select Custom JARs. From your local machine, select the downloaded MaxCompute JDBC driver JAR file, such as odps-jdbc-3.9.0-rc4-jar-with-dependencies.jar.

    Parameter

    Description

    Name

    A name for the new driver, such as MaxCompute.

    Class

    After uploading the MaxCompute JDBC driver JAR file, select com.aliyun.odps.jdbc.OdpsDriver from the drop-down list.

  7. Go to the Data Source tab. Click the image icon and select the driver that you created, such as MaxCompute.

  8. On the General tab, configure the following parameters.

    Parameter

    Description

    Name

    Defaults to the driver name. You can specify a custom name.

    Authentication

    Select User & Password.

    User

    The AccessKey ID with permissions to access the MaxCompute project.

    You can go to the AccessKey Management page to obtain the AccessKey ID.

    Password

    The AccessKey Secret that corresponds to the AccessKey ID.

    URL

    The connection URL for the MaxCompute project. The format is jdbc:odps:<MaxCompute_endpoint>?project=<MaxCompute_project_name>[&interactiveMode={true|false}]. Do not include the angle brackets (<>) in the URL. The following table describes the parameters.

    • <MaxCompute_endpoint>: Required. The endpoint for the region where your MaxCompute project is located.

      For a list of endpoints by region, see Endpoints.

    • <MaxCompute_project_name>: Required. The name of the MaxCompute project to connect to.

      This is the name of your MaxCompute project, not a workspace name. You can sign in to the MaxCompute console, switch to the correct region in the upper-left corner, and find the project name on the Projects page.

    • interactiveMode: Optional. Specifies whether to enable the query acceleration feature.

      To enable query acceleration, append &interactiveMode=true to the URL. For more information about this feature, see Query acceleration.

    • useProjectTimeZone: Optional. This parameter synchronizes the time zone between DataGrip and the MaxCompute server instance. To use the same time zone, append &useProjectTimeZone=true to the URL.

  9. Click Test Connection to verify the configuration.

  10. Click OK to save the configuration.

Step 2: Manage the project

After creating the connection, the new MaxCompute connection appears in the left panel. You can write and run SQL scripts to manage your MaxCompute project. For more information, see DataGrip Help.

  • View all tables

    You can view information about all tables under your MaxCompute connection.

    In the Database Explorer panel on the left, expand MaxCompute connection > project name > default > tables to view all tables in the schema.

  • View a table schema

    Right-click the target table, select Create > Query Console, and then write and run an SQL script in the SQL editor on the right to view the table schema.

    For example, run the DESC sale_detail command. The output lists the Native Columns, which include shop_name(STRING), customer_id(STRING), and total_price(DOUBLE), and the Partition Columns, which include sale_date(STRING) and region(STRING).

  • View table data

    Right-click the target table, select Create > Query Console, and then write and run an SQL script in the SQL editor on the right to view the table data.

    For example, to query the pyodps_iris table, run the SELECT * FROM pyodps_iris; command. Click the green triangle Run icon in the toolbar to view the table data in the Result panel at the bottom.