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 toodps.
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 inCatalogParams.
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 inScanParams.
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 inCachingMetaParams.
Examples
The following example creates a MaxCompute catalog namedodps_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:odps_catalog:
Drop a MaxCompute catalog
You can use DROP CATALOG to drop an external catalog. The following example drops a MaxCompute catalog namedodps_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
-
Use SHOW DATABASES to view the databases in your MaxCompute cluster:
-
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:
-
Use SELECT to query the destination table in the specified database:
Load data from MaxCompute
Suppose that there is an OLAP table namedolap_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 namedmc_table in your MaxCompute cluster. You can create a manual collection task for collecting CBO statistics by using ANALYZE TABLE: