Skip to main content
Beta feature Advice on use of Beta features The database supports Alibaba Cloud MaxCompute (previously known as ODPS) catalogs from v3.3 onwards. A MaxCompute catalog is a kind of external catalog that enables you to query data from MaxCompute without ingestion. With MaxCompute catalogs, you also can directly transform and load the data from MaxCompute by using INSERT INTO.

Usage notes

You can use MaxCompute catalogs only to query the data from MaxCompute. You cannot use MaxCompute catalogs to drop, delete, or insert data into your MaxCompute cluster.

Integration preparations

Before creating a MaxCompute catalog, make sure that your cluster can access your MaxCompute service properly.

Create a MaxCompute catalog

Syntax

Parameters

catalog_name

The name of the MaxCompute catalog. The naming conventions are as follows:
  • The name can contain letters, digits (0-9), and underscores (_). It must start with a letter.
  • The name is case-sensitive and cannot exceed 1023 characters in length.

comment

The description of the MaxCompute catalog. This parameter is optional.

type

The type of your data source. Set the value to odps.

CatalogParams

A set of parameters about how the database accesses the metadata of the MaxCompute cluster. The following table describes the parameter you need to configure in CatalogParams.

ScanParams

A set of parameters about how the database accesses the files stored in the MaxCompute cluster. This parameter set is optional. The following table describes the parameter you need to configure in ScanParams.

CachingMetaParams

A set of parameters about how the database caches the metadata of Hive. This parameter set is optional. The following table describes the parameter you need to configure in CachingMetaParams.

Examples

The following example creates a MaxCompute catalog named odps_catalog which uses odps_project as the warehouse project.

View MaxCompute catalogs

You can use SHOW CATALOGS to query all catalogs in the current cluster:
You can also use SHOW CREATE CATALOG to query the creation statement of an external catalog. The following example queries the creation statement of a MaxCompute catalog named odps_catalog:

Drop a MaxCompute catalog

You can use DROP CATALOG to drop an external catalog. The following example drops a MaxCompute catalog named odps_catalog:

View the schema of a MaxCompute table

You can use one of the following syntaxes to view the schema of a MaxCompute table:
  • View schema
  • View schema and location from the CREATE statement

Query a MaxCompute table

  1. Use SHOW DATABASES to view the databases in your MaxCompute cluster:
  2. Use SET CATALOG to switch to the destination catalog in the current session:
    Then, use USE to specify the active database in the current session:
    Or, you can use USE to directly specify the active database in the destination catalog:
  3. Use SELECT to query the destination table in the specified database:

Load data from MaxCompute

Suppose that there is an OLAP table named olap_tbl in your StarRock cluster and there is a table named mc_table in your MaxCompute cluster. You can transform and load the data from the MaxCompute table mc_table into the table olap_tbl like below:

Data type mapping

MaxCompute catalogs map the MaxCompute data types to the data types. The following table shows the mapping between the MaxCompute data types to the data types. Note The TIMESTAMP type will lose precision due to type conversion in the database.

Collect CBO statistics

In the current version, MaxCompute catalogs cannot automatically collect CBO statistics for MaxCompute tables, and consequently the optimizer may not be able to generate the optimal query plans. As such, manually scanning the CBO statistics for MaxCompute tables and importing them into the database can effectively expedite queries. Suppose that there is a MaxCompute table named mc_table in your MaxCompute cluster. You can create a manual collection task for collecting CBO statistics by using ANALYZE TABLE:

Manually update metadata cache

By default, the database caches the metadata of MaxCompute to improve query performance. Therefore, after making schema changes or other updates to a MaxCompute table, you can use REFRESH EXTERNAL TABLE to manually update the metadata of the table, thereby ensuring that the database can obtain the most recent metadata promptly: