External catalog collection
Data Map collects metadata from StarRocks external catalogs indirectly. If you use external catalogs in a StarRocks database, configure the associated data source and run a metadata collection task so that you can search for and view tables, columns, and other metadata in Data Map.
Background
By default, Data Map collects metadata only from the internal catalog of a StarRocks data source. To collect metadata from an external catalog, configure a connection to the associated data source in DataWorks and run a metadata collection task. After collection, Data Map automatically associates the metadata, and you can view the external catalog and its metadata within the StarRocks data source.
Prerequisites
-
You have added your StarRocks database as a StarRocks data source in DataWorks. For more information, see Add a StarRocks data source.
-
To collect metadata from a data source with allowlist-based access control, you must first configure the required permissions. For more information, see Configure a metadata collection allowlist.
Limitations
-
External catalogs of the Elasticsearch Catalog type are not supported.
-
Paimon Catalogs that use OSS as a source are not supported.
Procedure
The following example uses a MySQL external catalog in StarRocks. If you configure a MySQL database as mysql_catalog_db, you must create a MySQL metadata collector in Data Map. After the collector gathers metadata from the MySQL database, you can search for and view the metadata associated with the mysql_catalog_db catalog in StarRocks.
Step 1: Prepare the data
Create a MySQL data source
Create a MySQL data source with the database name mysql_catalog_db and create a sample table named mysql_catalog_table. The following is a sample script:
CREATE TABLE mysql_catalog_table(
catalog_table_id INT,
catalog_table_name VARCHAR(255)
)
Prepare the MySQL JDBC driver package
Upload the MySQL Java Database Connectivity (JDBC) driver for your MySQL version to OSS.
-
Upload the JDBC driver JAR package for your MySQL version to OSS. Log on to the OSS console. In the left-side navigation pane, click buckets.
-
Click the name of the destination bucket to open the Manage Files page. This example uses the
catalog-bucket-ossbucket. -
Click Create Directory to create a directory to store the JAR package. For Folder Name, enter
libs. -
Go to the directory that you created for the JDBC driver JAR package. Click Upload File. In the Files to Upload area, click Scan for Files, select the
mysql-connector-java-8.0.28.jarJDBC driver JAR package, and then click Upload File. -
Find the uploaded JDBC driver JAR package. In the Actions column for the file, click Details. On the Details page, click Set ACL. On the Set ACL page, set the file permission to Public Read/Write, and then click OK to enable public access.
Step 2: Configure the external connection
-
Connect to your StarRocks instance.
-
Log on to the EMR console. In the left-side navigation pane, choose EMR Serverless > StarRocks. Click Instances.
-
Find the StarRocks instance that you created and click Actions > Connect to Instance. The New Connection tab appears.
-
On the New Connection tab, select the Region and Instance name of your StarRocks instance. Enter a Connection Name, Username, and Password. Click Test Network Connectivity. After the connection is successful, click OK to go to the StarRocks instance Query page.
-
-
In StarRocks, configure an external catalog for MySQL.
-
Below the query list, click +File to open the Create File dialog box. Enter a Name, select a Storage Path, and click OK to create the file.
-
Under All Files, double-click the name of the file that you created to open the StarRocks instance editor. Enter the following sample script to create an external catalog. For more information, see StarRocks external catalog configuration examples.
CREATE EXTERNAL CATALOG mysql_db_catalog PROPERTIES ( "driver_class" = "com.mysql.cj.jdbc.Driver", "driver_url" = "https://catalog-bucket-oss.oss-cn-hangzhou-internal.aliyuncs.com/libs/mysql-connector-java-8.0.28.jar", "type" = "jdbc", "user" = "<UserName>", "password"="<PassWord>", "jdbc_uri" = "jdbc:mysql://xxx:3306/mysql_catalog_db" );Note-
mysql_db_catalogis the name of the external catalog for the MySQL data source. -
Replace
<UserName>and<PassWord>with your actual credentials. -
jdbc_uri: Enter the connection URL of the database that you created.
-
-
After editing, click Run to run the script. After the script runs successfully, you can view the related table information on the Database tab.
Click the External Catalog tab. In the Catalog drop-down list, select the catalog you created, such as
mysql_db_catalog. You can then expand it to view the corresponding database and table structures.
-
Step 3: Configure data sources
-
Log on to the DataWorks console. Switch to the target region. In the left-side navigation pane, click Workspace. In the Workspaces list, find the workspace that you want to manage and click Manage in the Actions column to open the Management Center.
-
In the left-side navigation pane of the Management Center, click . On the Data Sources page, add StarRocks and MySQL data sources. For more information, see [Deprecated] Configure a StarRocks data source and Configure a MySQL data source.
NoteFor the MySQL data source, you must select Connection String Mode. This mode is also required for any other JDBC-based external data source.
Step 4: Configure metadata collection
Log on to the DataWorks console. Switch to the target region. In the left-side navigation pane, choose , and then click Go to Data Map.
Internal catalog collection
Follow the steps in Create a custom collector to create a StarRocks collector.
External catalog collection
You must also complete metadata collection for the MySQL data source. Otherwise, metadata from the MySQL external catalog is not searchable.
In the MySQL metadata collection configuration, set the Data Sources for Which Crawlers Are Created field to MySQL.
Step 5: Search for metadata
After the StarRocks and MySQL metadata collection tasks are complete, click the
search icon on the left to open the search page.
-
On the Type tab, go to the Connection tab and select the StarRocks data source. Under Filter Conditions, select the StarRocks Instance you created, the external Data Catalog for MySQL, and the corresponding MySQL Database. You can then view the MySQL catalog information within the StarRocks data source.
The search results show a record for a MySQL catalog table, such as
mysql_catalog_table. This indicates that the metadata from the MySQL catalog has been successfully associated with the StarRocks data source. -
Alternatively, on the Type tab, go to the Connection tab and select the MySQL data source. Under Filter Conditions, select the name of the MySQL database you created and verify that the table information is consistent.
The search results show the table records from the MySQL data source, such as
mysql_catalog_table. If the table name and the number of records match the results from the StarRocks external catalog search, it confirms that the MySQL data source metadata collection is configured correctly. -
View table details.
Click the target table name to view its details.
The table details page contains three tabs: Details, Lineage, and Usage Notes. On the Details tab, the Column information section displays the Column name, Type, and Description of each column in a table. For example, the section displays columns such as
catalog_table_id(int) andcatalog_table_name(varchar).
StarRocks external catalog configuration examples
Use the following syntax to configure a StarRocks external catalog:
CREATE EXTERNAL CATALOG <Catalog_Name> COMMENT '' PROPERTIES("type"="","xxx1"="","xxx2"="");
Catalog_Name is the name of the external data catalog. You can customize this name.
The following table provides examples of how to configure a StarRocks external catalog. For more information, see Data Catalog.
|
Collection Mode |
Connection method |
Example |
|
Default Catalog |
default |
With the Default Catalog type, StarRocks collects its internal metadata by default, so you do not need to configure an external catalog. For more information, see Data analysis. |
|
ODPS Catalog |
VPC |
Note
Replace |
|
Hive Catalog |
Hive Metastore (HMS) |
Note
Replace the |
|
Data Lake Formation (DLF) |
Note
Replace the |
|
|
Iceberg Catalog |
Hive |
Note
When you use Hive Metastore as the metadata service and configure an Iceberg external catalog, replace the |
|
Hudi Catalog |
Hive |
Note
When you use Hive Metastore as the metadata service to configure a Hudi external catalog, replace the |
|
Data Lake Formation (DLF) |
Note
When you use DLF as the metadata service to configure an external Hudi catalog, replace the |
|
|
Delta Lake Catalog |
Hive |
Note
|
|
Data Lake Formation (DLF) |
Note
Replace the |
|
|
JDBC Catalog |
MySQL |
Note
|
|
PostgreSQL |
Note
|
|
|
Paimon Catalog |
Hive (supported in StarRocks 3.1 and later) |
Note
When you use Hive as the metadata service to configure a Paimon Catalog:
|
|
Data Lake Formation (DLF, supported in StarRocks 3.1 and later) |
Note
When you use DLF as the metadata service to configure a Paimon Catalog:
|
|
|
Unified Catalog |
Hive (supported in StarRocks 3.2 and later) |
Note
If you use Hive as the metadata service when you configure the Unified Catalog, replace the |