Project: StarRocks (App Definition and Development / Database)
File: deltalake_catalog.md

displayed_sidebar: "English" tocmaxheading_level: 5 A Delta Lake catalog is a kind of external catalog that enables you to query data from Delta Lake without ingestion. Also, you can directly transform and load data from Delta Lake by using based on Delta Lake catalogs. StarRocks supports Delta Lake catalogs from v2.5 onwards. To ensure successful SQL workloads on your Delta Lake cluster, your StarRocks cluster must be able to access the storage system and metastore of your Delta Lake cluster. StarRocks supports the following storage systems and metastores: Distributed file system (HDFS) or object storage like AWS S3, Microsoft Azure Storage, Google GCS, or other S3-compatible storage system (for example, MinIO) Metastore like Hive metastore or AWS Glue > NOTE > > If you choose AWS S3 as storage, you can use HMS or AWS Glue as metastore. If you choose any other storage system, you can only use HMS as metastore. The file format of Delta Lake that StarRocks supports is Parquet. Parquet files support the following compression formats: SNAPPY, LZ4, ZSTD, GZIP, and NO_COMPRESSION. The data types of Delta Lake that StarRocks does not support are MAP and STRUCT. Before you create a Delta Lake catalog, make sure your StarRocks cluster can integrate with the storage system and metastore of your Delta Lake cluster. If your Delta Lake cluster uses AWS S3 as storage or AWS Glue as metastore, choose your suitable authentication method and make the required preparations to ensure that your StarRocks cluster can access the related AWS cloud resources. The following authentication methods are recommended: Instance profile Assumed role IAM user Of the above-mentioned three authentication methods, instance profile is the most widely used. For more information, see . If you choose HDFS as storage, configure your StarRocks cluster as follows: (Optional) Set the username that is used to access your HDFS cluster and Hive metastore. By default, StarRocks uses the username of the FE and BE or CN processes to access your HDFS cluster and Hive metastore. You can also set the username by adding `export HADOOPUSERNAME="<username>"` at the beginning of the **fe/conf/hadoopenv.sh file of each FE and at the beginning of the be/conf/hadoopenv.sh** file of each BE or the **cn/conf/hadoopenv.sh file of each CN. After you set the username in these files, restart each FE and each BE or CN to make the parameter settings take effect. You can set only one username for each StarRocks cluster. When you query Delta Lake data, the FEs and BEs or CNs of your StarRocks cluster use the HDFS client to access your HDFS cluster. In most cases, you do not need to configure your StarRocks cluster to achieve that purpose, and StarRocks starts the HDFS client using the default configurations. You need to configure your StarRocks cluster only in the following situations: High availability (HA) is enabled for your HDFS cluster: Add the hdfs-site.xml file of your HDFS cluster to the $FE_HOME/conf path of each FE and to the $BE_HOME/conf path of each BE or the $CN_HOME/conf path of each CN. View File System (ViewFs) is enabled for your HDFS cluster: Add the core-site.xml file of your HDFS cluster to the $FE_HOME/conf path of each FE and to the $BE_HOME/conf path of each BE or the $CN_HOME/conf path of each CN. NOTE If an error indicating an unknown host is returned when you send a query, you must add the mapping between the host names and IP addresses of your HDFS cluster nodes to the /etc/hosts

If Kerberos authentication is enabled for your HDFS cluster or Hive metastore, configure your StarRocks cluster as follows: Run the `kinit -kt keytab_path principal` command on each FE and each BE or CN to obtain Ticket Granting Ticket (TGT) from Key Distribution Center (KDC). To run this command, you must have the permissions to access your HDFS cluster and Hive metastore. Note that accessing KDC with this command is time-sensitive. Therefore, you need to use cron to run this command periodically. Add `JAVAOPTS="-Djava.security.krb5.conf=/etc/krb5.conf"` to the **$FEHOME/conf/fe.conf file of each FE and to the $BEHOME/conf/be.conf** file of each BE or the **$CNHOME/conf/cn.conf file of each CN. In this example, `/etc/krb5.conf` is the save path of the krb5.conf file. You can modify the path based on your needs. ```SQL CREATE EXTERNAL CATALOG <catalog_name> [COMMENT <comment>] PROPERTIES ( "type" = "deltalake", MetastoreParams, StorageCredentialParams, MetadataUpdateParams ) ``` The name of the Delta Lake 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. The description of the Delta Lake catalog. This parameter is optional. The type of your data source. Set the value to `deltalake`. A set of parameters about how StarRocks integrates with the metastore of your data source. If you choose Hive metastore as the metastore of your data source, configure `MetastoreParams` as follows: ```SQL "hive.metastore.type" = "hive", "hive.metastore.uris" = "<hivemetastoreuri>" ``` NOTE Before querying Delta Lake data, you must add the mapping between the host names and IP addresses of your Hive metastore nodes to the `/etc/hosts` path. Otherwise, StarRocks may fail to access your Hive metastore when you start a query. The following table describes the parameter you need to configure in `MetastoreParams`. | Parameter | Required | Description | | - | -- | | | hive.metastore.type | Yes | The type of metastore that you use for your Delta Lake cluster. Set the value to `hive`. | | hive.metastore.uris | Yes | The URI of your Hive metastore. Format: `thrift://<metastoreIPaddress>:<metastoreport>`.<br />If high availability (HA) is enabled for your Hive metastore, you can specify multiple metastore URIs and separate them with commas (`,`), for example, `"thrift://<metastoreIPaddress1>:<metastoreport1>,thrift://<metastoreIPaddress2>:<metastoreport2>,thrift://<metastoreIPaddress3>:<metastoreport3>"`. | If you choose AWS Glue as the metastore of your data source, which is supported only when you choose AWS S3 as storage, take one of the following actions: To choose the instance profile-based authentication method, configure `MetastoreParams` as follows: ```SQL "hive.metastore.type" = "glue", "aws.glue.useinstanceprofile" = "true", "aws.glue.region" = "<awsglueregion>" ``` To choose the assumed role-based authentication method, configure `MetastoreParams` as follows: ```SQL "hive.metastore.type" = "glue", "aws.glue.useinstanceprofile" = "true", "aws.glue.iamrolearn" = "<iamrolearn>", "aws.glue.region" = "<awsglueregion>" ``` To choose the IAM user-based authentication method, configure `MetastoreParams` as follows: ```SQL "hive.metastore.type" = "glue", "aws.glue.useinstanceprofile" = "false", "aws.glue.accesskey" = "<iamuseraccesskey>", "aws.glue.secretkey" = "<iamusersecretkey>", "aws.glue.region" = "<awss3region>" ``` The following table describes the parameters you need to configure in `MetastoreParams`. | Parameter | Required | Description | | -- | -- | | | hive.metastore.type | Yes | The type of metastore that you use for your Delta Lake cluster. Set the value to `glue`. | | aws.glue.useinstanceprofile | Yes | Specifies whether to enable the instance profile-based authentication method and the assumed role-based authentication method. Valid values: `true` and `false`. Default value: `false`. | | aws.glue.iamrolearn | No | The ARN of the IAM role that has privileges on your AWS Glue Data

If you use the assumed role-based authentication method to access AWS Glue, you must specify this parameter. | | aws.glue.region | Yes | The region in which your AWS Glue Data Catalog resides. Example: `us-west-1`. | | aws.glue.access_key | No | The access key of your AWS IAM user. If you use the IAM user-based authentication method to access AWS Glue, you must specify this parameter. | | aws.glue.secret_key | No | The secret key of your AWS IAM user. If you use the IAM user-based authentication method to access AWS Glue, you must specify this parameter. | For information about how to choose an authentication method for accessing AWS Glue and how to configure an access control policy in the AWS IAM Console, see . A set of parameters about how StarRocks integrates with your storage system. This parameter set is optional. If you use HDFS as storage, you do not need to configure `StorageCredentialParams`. If you use AWS S3, other S3-compatible storage system, Microsoft Azure Storage, or Google GCS as storage, you must configure `StorageCredentialParams`. If you choose AWS S3 as storage for your Delta Lake cluster, take one of the following actions: To choose the instance profile-based authentication method, configure `StorageCredentialParams` as follows: ```SQL "aws.s3.useinstanceprofile" = "true", "aws.s3.region" = "<awss3region>" ``` To choose the assumed role-based authentication method, configure `StorageCredentialParams` as follows: ```SQL "aws.s3.useinstanceprofile" = "true", "aws.s3.iamrolearn" = "<iamrolearn>", "aws.s3.region" = "<awss3region>" ``` To choose the IAM user-based authentication method, configure `StorageCredentialParams` as follows: ```SQL "aws.s3.useinstanceprofile" = "false", "aws.s3.accesskey" = "<iamuseraccesskey>", "aws.s3.secretkey" = "<iamusersecretkey>", "aws.s3.region" = "<awss3region>" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Required | Description | | | -- | | | aws.s3.useinstanceprofile | Yes | Specifies whether to enable the instance profile-based authentication method and the assumed role-based authentication method. Valid values: `true` and `false`. Default value: `false`. | | aws.s3.iamrolearn | No | The ARN of the IAM role that has privileges on your AWS S3 bucket. If you use the assumed role-based authentication method to access AWS S3, you must specify this parameter. | | aws.s3.region | Yes | The region in which your AWS S3 bucket resides. Example: `us-west-1`. | | aws.s3.access_key | No | The access key of your IAM user. If you use the IAM user-based authentication method to access AWS S3, you must specify this parameter. | | aws.s3.secret_key | No | The secret key of your IAM user. If you use the IAM user-based authentication method to access AWS S3, you must specify this parameter. | For information about how to choose an authentication method for accessing AWS S3 and how to configure an access control policy in AWS IAM Console, see . Delta Lake catalogs support S3-compatible storage systems from v2.5 onwards. If you choose an S3-compatible storage system, such as MinIO, as storage for your Delta Lake cluster, configure `StorageCredentialParams` as follows to ensure a successful integration: ```SQL "aws.s3.enable_ssl" = "false", "aws.s3.enablepathstyle_access" = "true", "aws.s3.endpoint" = "<s3_endpoint>", "aws.s3.accesskey" = "<iamuseraccesskey>", "aws.s3.secretkey" = "<iamusersecretkey>" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Required | Description | | -- | -- | | | aws.s3.enable_ssl | Yes | Specifies whether to enable SSL connection.<br />Valid values: `true` and `false`. Default value: `true`. | | aws.s3.enablepathstyleaccess | Yes | Specifies whether to enable path-style access.<br />Valid values: `true` and `false`. Default value: `false`. For MinIO, you must set the value to

/>Path-style URLs use the following format: `https://s3.<regioncode>.amazonaws.com/<bucketname>/<keyname>`. For example, if you create a bucket named `DOC-EXAMPLE-BUCKET1` in the US West (Oregon) Region, and you want to access the `alice.jpg` object in that bucket, you can use the following path-style URL: `https://s3.us-west-2.amazonaws.com/DOC-EXAMPLE-BUCKET1/alice.jpg`. | | aws.s3.endpoint | Yes | The endpoint that is used to connect to your S3-compatible storage system instead of AWS S3. | | aws.s3.access_key | Yes | The access key of your IAM user. | | aws.s3.secret_key | Yes | The secret key of your IAM user. | Delta Lake catalogs support Microsoft Azure Storage from v3.0 onwards. If you choose Blob Storage as storage for your Delta Lake cluster, take one of the following actions: To choose the Shared Key authentication method, configure `StorageCredentialParams` as follows: ```SQL "azure.blob.storageaccount" = "<storageaccount_name>", "azure.blob.sharedkey" = "<storageaccountsharedkey>" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Required | Description | | -- | | -- | | azure.blob.storage_account | Yes | The username of your Blob Storage account. | | azure.blob.shared_key | Yes | The shared key of your Blob Storage account. | To choose the SAS Token authentication method, configure `StorageCredentialParams` as follows: ```SQL "azure.blob.storageaccount" = "<storageaccount_name>", "azure.blob.container" = "<container_name>", "azure.blob.sastoken" = "<storageaccountSAStoken>" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Required | Description | | - | | | | azure.blob.storage_account| Yes | The username of your Blob Storage account. | | azure.blob.container | Yes | The name of the blob container that stores your data. | | azure.blob.sas_token | Yes | The SAS token that is used to access your Blob Storage account. | If you choose Data Lake Storage Gen2 as storage for your Delta Lake cluster, take one of the following actions: To choose the Managed Identity authentication method, configure `StorageCredentialParams` as follows: ```SQL "azure.adls2.oauth2usemanaged_identity" = "true", "azure.adls2.oauth2tenantid" = "<serviceprincipaltenant_id>", "azure.adls2.oauth2clientid" = "<serviceclientid>" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Required | Description | | | | | | azure.adls2.oauth2usemanaged_identity | Yes | Specifies whether to enable the Managed Identity authentication method. Set the value to `true`. | | azure.adls2.oauth2tenantid | Yes | The ID of the tenant whose data you want to access. | | azure.adls2.oauth2clientid | Yes | The client (application) ID of the managed identity. | To choose the Shared Key authentication method, configure `StorageCredentialParams` as follows: ```SQL "azure.adls2.storageaccount" = "<storageaccount_name>", "azure.adls2.sharedkey" = "<storageaccountsharedkey>" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Required | Description | | | | | | azure.adls2.storage_account | Yes | The username of your Data Lake Storage Gen2 storage account. | | azure.adls2.shared_key | Yes | The shared key of your Data Lake Storage Gen2 storage account. | To choose the Service Principal authentication method, configure `StorageCredentialParams` as follows: ```SQL "azure.adls2.oauth2clientid" = "<serviceclientid>", "azure.adls2.oauth2clientsecret" = "<serviceprincipalclient_secret>", "azure.adls2.oauth2clientendpoint" = "<serviceprincipalclient_endpoint>" ``` The following table describes the parameters you need to configure `in StorageCredentialParams`. | Parameter | Required | Description | | - | | | | azure.adls2.oauth2clientid | Yes | The client (application) ID of the service principal. | | azure.adls2.oauth2clientsecret | Yes | The value of the new client (application) secret created. | | azure.adls2.oauth2clientendpoint | Yes | The OAuth 2.0 token endpoint (v1) of the service principal or

| If you choose Data Lake Storage Gen1 as storage for your Delta Lake cluster, take one of the following actions: To choose the Managed Service Identity authentication method, configure `StorageCredentialParams` as follows: ```SQL "azure.adls1.usemanagedservice_identity" = "true" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Required | Description | | - | | | | azure.adls1.usemanagedservice_identity | Yes | Specifies whether to enable the Managed Service Identity authentication method. Set the value to `true`. | To choose the Service Principal authentication method, configure `StorageCredentialParams` as follows: ```SQL "azure.adls1.oauth2clientid" = "<applicationclientid>", "azure.adls1.oauth2credential" = "<applicationclient_credential>", "azure.adls1.oauth2endpoint" = "<OAuth2.0authorizationendpoint_v2>" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Required | Description | | -- | | | | azure.adls1.oauth2clientid | Yes | The client (application) ID of the service principal. | | azure.adls1.oauth2_credential | Yes | The value of the new client (application) secret created. | | azure.adls1.oauth2_endpoint | Yes | The OAuth 2.0 token endpoint (v1) of the service principal or application. | Delta Lake catalogs support Google GCS from v3.0 onwards. If you choose Google GCS as storage for your Delta Lake cluster, take one of the following actions: To choose the VM-based authentication method, configure `StorageCredentialParams` as follows: ```SQL "gcp.gcs.usecomputeengineserviceaccount" = "true" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Default value | Value example | Description | | | -- | | | | gcp.gcs.usecomputeengineserviceaccount | false | true | Specifies whether to directly use the service account that is bound to your Compute Engine. | To choose the service account-based authentication method, configure `StorageCredentialParams` as follows: ```SQL "gcp.gcs.serviceaccountemail" = "<googleserviceaccount_email>", "gcp.gcs.serviceaccountprivatekeyid" = "<googleserviceprivatekeyid>", "gcp.gcs.serviceaccountprivatekey" = "<googleserviceprivatekey>", ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Default value | Value example | Description | | -- | -- | | | | gcp.gcs.serviceaccountemail | "" | "" | The email address in the JSON file generated at the creation of the service account. | | gcp.gcs.serviceaccountprivatekeyid | "" | "61d257bd8479547cb3e04f0b9b6b9ca07af3b7ea" | The private key ID in the JSON file generated at the creation of the service account. | | gcp.gcs.serviceaccountprivate_key | "" | "--BEGIN PRIVATE KEY-xxxx--END PRIVATE KEY--\n" | The private key in the JSON file generated at the creation of the service account. | To choose the impersonation-based authentication method, configure `StorageCredentialParams` as follows: Make a VM instance impersonate a service account: ```SQL "gcp.gcs.usecomputeengineserviceaccount" = "true", "gcp.gcs.impersonationserviceaccount" = "<assumedgoogleserviceaccountemail>" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Default value | Value example | Description | | | -- | | | | gcp.gcs.usecomputeengineserviceaccount | false | true | Specifies whether to directly use the service account that is bound to your Compute Engine. | | gcp.gcs.impersonationserviceaccount | "" | "hello" | The service account that you want to impersonate. | Make a service account (temporarily named as meta service account) impersonate another service account (temporarily named as data service account): ```SQL "gcp.gcs.serviceaccountemail" = "<googleserviceaccount_email>", "gcp.gcs.serviceaccountprivatekeyid" = "<metagoogleserviceaccountemail>", "gcp.gcs.serviceaccountprivatekey" = "<metagoogleserviceaccount_email>", "gcp.gcs.impersonationserviceaccount" = "<datagoogleserviceaccountemail>" ``` The following table describes the parameters you need to configure in `StorageCredentialParams`. | Parameter | Default value | Value example | Description | | -- | -- | | | | gcp.gcs.serviceaccountemail | "" | "" | The email address in the JSON file generated at the creation of the meta service account. | | gcp.gcs.serviceaccountprivatekeyid | "" | "61d257bd8479547cb3e04f0b9b6b9ca07af3b7ea" | The private key ID in the JSON file generated at the creation of the meta service

| | gcp.gcs.serviceaccountprivate_key | "" | "--BEGIN PRIVATE KEY-xxxx--END PRIVATE KEY--\n" | The private key in the JSON file generated at the creation of the meta service account. | | gcp.gcs.impersonationserviceaccount | "" | "hello" | The data service account that you want to impersonate. | A set of parameters about how StarRocks updates the cached metadata of Delta Lake. This parameter set is optional. StarRocks implements the by default. In most cases, you can ignore `MetadataUpdateParams` and do not need to tune the policy parameters in it, because the default values of these parameters already provide you with an out-of-the-box performance. However, if the frequency of data updates in Delta Lake is high, you can tune these parameters to further optimize the performance of automatic asynchronous updates. NOTE In most cases, if your Delta Lake data is updated at a granularity of 1 hour or less, the data update frequency is considered high. | Parameter | Required | Description | |-| -- | | | enablemetastorecache | No | Specifies whether StarRocks caches the metadata of Delta Lake tables. Valid values: `true` and `false`. Default value: `true`. The value `true` enables the cache, and the value `false` disables the cache. | | enableremotefile_cache | No | Specifies whether StarRocks caches the metadata of the underlying data files of Delta Lake tables or partitions. Valid values: `true` and `false`. Default value: `true`. The value `true` enables the cache, and the value `false` disables the cache. | | metastorecacherefreshintervalsec | No | The time interval at which StarRocks asynchronously updates the metadata of Delta Lake tables or partitions cached in itself. Unit: seconds. Default value: `7200`, which is 2 hours. | | remotefilecacherefreshinterval_sec | No | The time interval at which StarRocks asynchronously updates the metadata of the underlying data files of Delta Lake tables or partitions cached in itself. Unit: seconds. Default value: `60`. | | metastorecachettl_sec | No | The time interval at which StarRocks automatically discards the metadata of Delta Lake tables or partitions cached in itself. Unit: seconds. Default value: `86400`, which is 24 hours. | | remotefilecachettlsec | No | The time interval at which StarRocks automatically discards the metadata of the underlying data files of Delta Lake tables or partitions cached in itself. Unit: seconds. Default value: `129600`, which is 36 hours. | The following examples create a Delta Lake catalog named `deltalakecataloghms` or `deltalakecatalogglue`, depending on the type of metastore you use, to query data from your Delta Lake cluster. If you use HDFS as storage, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083" ); ``` If you use Hive metastore in your Delta Lake cluster, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "aws.s3.useinstanceprofile" = "true", "aws.s3.region" = "us-west-2" ); ``` If you use AWS Glue in your Amazon EMR Delta Lake cluster, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecatalogglue PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "glue", "aws.glue.useinstanceprofile" = "true", "aws.glue.region" = "us-west-2", "aws.s3.useinstanceprofile" = "true", "aws.s3.region" = "us-west-2" ); ``` If you use Hive metastore in your Delta Lake cluster, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "aws.s3.useinstanceprofile" = "true", "aws.s3.iamrolearn" = "arn:aws:iam::081976408565:role/tests3role",

= "us-west-2" ); ``` If you use AWS Glue in your Amazon EMR Delta Lake cluster, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecatalogglue PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "glue", "aws.glue.useinstanceprofile" = "true", "aws.glue.iamrolearn" = "arn:aws:iam::081976408565:role/testgluerole", "aws.glue.region" = "us-west-2", "aws.s3.useinstanceprofile" = "true", "aws.s3.iamrolearn" = "arn:aws:iam::081976408565:role/tests3role", "aws.s3.region" = "us-west-2" ); ``` If you use Hive metastore in your Delta Lake cluster, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "aws.s3.useinstanceprofile" = "false", "aws.s3.accesskey" = "<iamuseraccesskey>", "aws.s3.secretkey" = "<iamuseraccesskey>", "aws.s3.region" = "us-west-2" ); ``` If you use AWS Glue in your Amazon EMR Delta Lake cluster, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecatalogglue PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "glue", "aws.glue.useinstanceprofile" = "false", "aws.glue.accesskey" = "<iamuseraccesskey>", "aws.glue.secretkey" = "<iamusersecretkey>", "aws.glue.region" = "us-west-2", "aws.s3.useinstanceprofile" = "false", "aws.s3.accesskey" = "<iamuseraccesskey>", "aws.s3.secretkey" = "<iamusersecretkey>", "aws.s3.region" = "us-west-2" ); ``` Use MinIO as an example. Run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "aws.s3.enable_ssl" = "true", "aws.s3.enablepathstyle_access" = "true", "aws.s3.endpoint" = "<s3_endpoint>", "aws.s3.accesskey" = "<iamuseraccesskey>", "aws.s3.secretkey" = "<iamusersecretkey>" ); ``` If you choose the Shared Key authentication method, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "azure.blob.storageaccount" = "<blobstorageaccountname>", "azure.blob.sharedkey" = "<blobstorageaccountshared_key>" ); ``` If you choose the SAS Token authentication method, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "azure.blob.storageaccount" = "<blobstorageaccountname>", "azure.blob.container" = "<blobcontainername>", "azure.blob.sastoken" = "<blobstorageaccountSAS_token>" ); ``` If you choose the Managed Service Identity authentication method, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "azure.adls1.usemanagedservice_identity" = "true" ); ``` If you choose the Service Principal authentication method, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "azure.adls1.oauth2clientid" = "<applicationclientid>", "azure.adls1.oauth2credential" = "<applicationclient_credential>", "azure.adls1.oauth2endpoint" = "<OAuth2.0authorizationendpoint_v2>" ); ``` If you choose the Managed Identity authentication method, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "azure.adls2.oauth2usemanaged_identity" = "true", "azure.adls2.oauth2tenantid" = "<serviceprincipaltenant_id>", "azure.adls2.oauth2clientid" = "<serviceclientid>" ); ``` If you choose the Shared Key authentication method, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "azure.adls2.storageaccount" = "<storageaccount_name>", "azure.adls2.sharedkey" = "<sharedkey>" ); ``` If you choose the Service Principal authentication method, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "azure.adls2.oauth2clientid" = "<serviceclientid>", "azure.adls2.oauth2clientsecret" = "<serviceprincipalclient_secret>", "azure.adls2.oauth2clientendpoint" = "<serviceprincipalclient_endpoint>" ); ``` If you choose the VM-based authentication method, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "gcp.gcs.usecomputeengineserviceaccount" = "true" ); ``` If you choose the service account-based authentication method, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "gcp.gcs.serviceaccountemail" = "<googleserviceaccount_email>", "gcp.gcs.serviceaccountprivatekeyid" = "<googleserviceprivatekeyid>", "gcp.gcs.serviceaccountprivatekey" = "<googleserviceprivatekey>" ); ``` If you choose the impersonation-based authentication method: If you make a VM instance impersonate a service account, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "gcp.gcs.usecomputeengineserviceaccount" = "true",

= "<assumedgoogleserviceaccountemail>" ); ``` If you make a service account impersonate another service account, run a command like below: ```SQL CREATE EXTERNAL CATALOG deltalakecataloghms PROPERTIES ( "type" = "deltalake", "hive.metastore.type" = "hive", "hive.metastore.uris" = "thrift://xx.xx.xx.xx:9083", "gcp.gcs.serviceaccountemail" = "<googleserviceaccount_email>", "gcp.gcs.serviceaccountprivatekeyid" = "<metagoogleserviceaccountemail>", "gcp.gcs.serviceaccountprivatekey" = "<metagoogleserviceaccount_email>", "gcp.gcs.impersonationserviceaccount" = "<datagoogleserviceaccountemail>" ); ``` You can use to query all catalogs in the current StarRocks cluster: ```SQL SHOW CATALOGS; ``` You can also use to query the creation statement of an external catalog. The following example queries the creation statement of a Delta Lake catalog named `deltalakecatalogglue`: ```SQL SHOW CREATE CATALOG deltalakecatalogglue; ``` You can use one of the following methods to switch to a Delta Lake catalog and a database in it: Use to specify a Delta Lake catalog in the current session, and then use to specify an active database: ```SQL -- Switch to a specified catalog in the current session: SET CATALOG <catalog_name> -- Specify the active database in the current session: USE <db_name> ``` Directly use to switch to a Delta Lake catalog and a database in it: ```SQL USE <catalogname>.<dbname> ``` You can use to drop an external catalog. The following example drops a Delta Lake catalog named `deltalakecatalogglue`: ```SQL DROP Catalog deltalakecatalogglue; ``` You can use one of the following syntaxes to view the schema of a Delta Lake table: View schema ```SQL DESC[RIBE] <catalogname>.<databasename>.<table_name> ``` View schema and location from the CREATE statement ```SQL SHOW CREATE TABLE <catalogname>.<databasename>.<table_name> ``` Use to view the databases in your Delta Lake cluster: ```SQL SHOW DATABASES FROM <catalog_name> ``` . Use to query the destination table in the specified database: ```SQL SELECT count(*) FROM <table_name> LIMIT 10 ``` Suppose you have an OLAP table named `olap_tbl`, you can transform and load data like below: ```SQL INSERT INTO defaultcatalog.olapdb.olaptbl SELECT * FROM deltalaketable ``` By default, StarRocks caches the metadata of Delta Lake and automatically updates the metadata in asynchronous mode to deliver better performance. Additionally, after some schema changes or table updates are made on a Delta Lake table, you can also use to manually update its metadata, thereby ensuring that StarRocks can obtain up-to-date metadata at its earliest opportunity and generate appropriate execution plans: ```SQL REFRESH EXTERNAL TABLE <table_name> ``` Unlike the automatic asynchronous update policy, the automatic incremental update policy enables the FEs in your StarRocks cluster to read events, such as adding columns, removing partitions, and updating data, from your Hive metastore. StarRocks can automatically update the metadata cached in the FEs based on these events. This means you do not need to manually update the metadata of your Delta Lake tables. To enable automatic incremental update, follow these steps: Both Hive metastore v2.x and v3.x support configuring an event listener. This step uses the event listener configuration used for Hive metastore v3.1.2 as an example. Add the following configuration items to the $HiveMetastore/conf/hive-site.xml file, and then restart your Hive metastore: ```XML <property> <name>hive.metastore.event.db.notification.api.auth</name> <value>false</value> </property> <property> <name>hive.metastore.notifications.add.thrift.objects</name> <value>true</value> </property> <property> <name>hive.metastore.alter.notifications.basic</name> <value>false</value> </property> <property> <name>hive.metastore.dml.events</name> <value>true</value> </property> <property> <name>hive.metastore.transactional.event.listeners</name> <value>org.apache.hive.hcatalog.listener.DbNotificationListener</value> </property> <property> <name>hive.metastore.event.db.listener.timetolive</name> <value>172800s</value> </property> <property> <name>hive.metastore.server.max.message.size</name> <value>858993459</value> </property> ``` You can search for `event id` in the FE log file to check whether the event listener is successfully configured. If the configuration fails, `event id` values are `0`. You can enable automatic incremental update for a single Delta Lake catalog or for all Delta Lake catalogs in your StarRocks

To enable automatic incremental update for a single Delta Lake catalog, set the `enablehmseventsincrementalsync` parameter to `true` in `PROPERTIES` like below when you create the Delta Lake catalog: ```SQL CREATE EXTERNAL CATALOG <catalog_name> [COMMENT <comment>] PROPERTIES ( "type" = "deltalake", "hive.metastore.uris" = "thrift://102.168.xx.xx:9083", .... "enablehmseventsincrementalsync" = "true" ); ``` To enable automatic incremental update for all Delta Lake catalogs, add `"enablehmseventsincrementalsync" = "true"` to the `$FE_HOME/conf/fe.conf` file of each FE, and then restart each FE to make the parameter setting take effect. You can also tune the following parameters in the `$FE_HOME/conf/fe.conf` file of each FE based on your business requirements, and then restart each FE to make the parameter settings take effect. | Parameter | Description | | | | | hmseventspollingintervalms | The time interval at which StarRocks reads events from your Hive metastore. Default value: `5000`. Unit: milliseconds. | | hmseventsbatchsizeper_rpc | The maximum number of events that StarRocks can read at a time. Default value: `500`. | | enablehmsparallelprocessevens | Specifies whether StarRocks processes events in parallel as it reads the events. Valid values: `true` and `false`. Default value: `true`. The value `true` enables parallelism, and the value `false` disables parallelism. | | hmsprocesseventsparallelnum | The maximum number of events that StarRocks can process in parallel. Default value: `4`. | Automatic asynchronous update is the default policy that StarRocks uses to update the metadata in Delta Lake catalogs. By default (namely, when the `enablemetastorecache` and `enableremotefile_cache` parameters are both set to `true`), if a query hits a partition of a Delta Lake table, StarRocks automatically caches the metadata of the partition and the metadata of the underlying data files of the partition. The cached metadata is updated by using the lazy update policy. For example, there is a Delta Lake table named `table2`, which has four partitions: `p1`, `p2`, `p3`, and `p4`. A query hits `p1`, and StarRocks caches the metadata of `p1` and the metadata of the underlying data files of `p1`. Assume that the default time intervals to update and discard the cached metadata are as follows: The time interval (specified by the `metastorecacherefreshintervalsec` parameter) to asynchronously update the cached metadata of `p1` is 2 hours. The time interval (specified by the `remotefilecacherefreshinterval_sec` parameter) to asynchronously update the cached metadata of the underlying data files of `p1` is 60 seconds. The time interval (specified by the `metastorecachettl_sec` parameter) to automatically discard the cached metadata of `p1` is 24 hours. The time interval (specified by the `remotefilecachettlsec` parameter) to automatically discard the cached metadata of the underlying data files of `p1` is 36 hours. The following figure shows the time intervals on a timeline for easier understanding. Then StarRocks updates or discards the metadata in compliance with the following rules: If another query hits `p1` again and the current time from the last update is less than 60 seconds, StarRocks does not update the cached metadata of `p1` or the cached metadata of the underlying data files of `p1`. If another query hits `p1` again and the current time from the last update is more than 60 seconds, StarRocks updates the cached metadata of the underlying data files of `p1`. If another query hits `p1` again and the current time from the last update is more than 2 hours, StarRocks updates the cached metadata of `p1`. If `p1` has not been accessed within 24 hours from the last update, StarRocks discards the cached metadata of `p1`. The metadata will be cached at the next query. If `p1` has not been accessed within 36 hours from the last update, StarRocks discards the cached metadata of the