maomaodev commented on code in PR #7667: URL: https://github.com/apache/kyuubi/pull/7667#discussion_r3877871083
########## docs/connector/spark/hive.md: ########## @@ -0,0 +1,166 @@ +<!-- +- Licensed to the Apache Software Foundation (ASF) under one or more +- contributor license agreements. See the NOTICE file distributed with +- this work for additional information regarding copyright ownership. +- The ASF licenses this file to You under the Apache License, Version 2.0 +- (the "License"); you may not use this file except in compliance with +- the License. You may obtain a copy of the License at +- +- http://www.apache.org/licenses/LICENSE-2.0 +- +- Unless required by applicable law or agreed to in writing, software +- distributed under the License is distributed on an "AS IS" BASIS, +- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +- See the License for the specific language governing permissions and +- limitations under the License. +--> + +# Hive + +You may know that the Apache Spark has built-in support for accessing Hive tables, it works well in most cases, +but is limited to one Hive Metastore. The Kyuubi Spark Hive connector(KSHC) implemented a Hive connector based +on Spark DataSource V2 API, supports accessing multiple Hive Metastore in a single Spark application. + +## Hive Integration + +To enable the integration of Kyuubi Spark SQL engine and Hive connector through +Spark DataSource V2 API, you need to: + +- Referencing the Hive connector [dependencies](#kshc-dependencies) +- Setting the Spark catalog [configurations](#kshc-configurations) + +(kshc-dependencies)= + +### Dependencies + +The **classpath** of Kyuubi Spark SQL engine with Hive connector supported consists of + +1. kyuubi-spark-sql-engine-{{ release }}_2.12.jar, the engine jar deployed with a Kyuubi distribution +2. a copy of Spark distribution +3. kyuubi-spark-connector-hive_2.12-{{ release }}, which can be found in the [Maven Central](https://mvnrepository.com/artifact/org.apache.kyuubi/kyuubi-spark-connector-hive) + +In order to make the Hive connector packages visible for the runtime classpath of engines, we can use one of these methods: + +1. Put the Kyuubi Hive connector packages into `$SPARK_HOME/jars` directly +2. Set `spark.jars=/path/to/kyuubi-hive-connector` + +```{note} +Starting from v1.9.2 and v1.10.0, KSHC jars available in the [Maven Central](https://mvnrepository.com/artifact/org.apache.kyuubi/kyuubi-spark-connector-hive) guarantee binary compatibility across +multiple Spark versions, so a single jar works across them without rebuilding. +``` + +(kshc-configurations)= + +### Configurations + +To activate functionality of Kyuubi Spark Hive connector, we can set the following configurations: + +```properties +spark.sql.catalog.hive_catalog org.apache.kyuubi.spark.connector.hive.HiveTableCatalog +spark.sql.catalog.hive_catalog.hive.metastore.uris thrift://metastore-host:port +spark.sql.catalog.hive_catalog.<other.hive.conf> <value> +spark.sql.catalog.hive_catalog.<other.hadoop.conf> <value> +``` + +Besides the catalog-level configurations above, the Kyuubi Spark Hive connector provides the following configurations: + +| Key | Default | Meaning | Type | Since | +|----------------------------------------------------------------|-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|--------| +| `spark.sql.kyuubi.hive.connector.externalCatalog.share.policy` | `ONE_FOR_ALL` | The share policy for the external catalog. `ONE_FOR_ONE` means an external catalog is used by only one `HiveTableCatalog`, while `ONE_FOR_ALL` shares an external catalog globally across the catalogs with the same name. | string | 1.7.0 | +| `spark.sql.catalog.<catalog>.delegation.token.renewal.enabled` | `true` | Whether to enable delegation token renewal for the Kerberized Hive Metastore of this catalog. | boolean | 1.8.0 | +| `spark.sql.kyuubi.hive.connector.read.convertMetastoreParquet` | `true` | When enabled, the data source Parquet reader is used to process Parquet tables created by HiveQL syntax, instead of the Hive SerDe. | boolean | 1.11.0 | +| `spark.sql.kyuubi.hive.connector.read.convertMetastoreOrc` | `true` | When enabled, the data source ORC reader is used to process ORC tables created by HiveQL syntax, instead of the Hive SerDe. | boolean | 1.11.0 | +| `spark.sql.kyuubi.hive.connector.dropTableAsPurgeTable` | `false` | When enabled, `DROP TABLE` completely removes its data by skipping HDFS trash, equivalent to the `PURGE TABLE` command. | boolean | 1.12.0 | +| `spark.sql.catalog.<catalog>.hive.metastore.warehouse.dir` | <undefined> | The default warehouse directory for the catalog, taking precedence over the global `spark.sql.warehouse.dir` when creating a database. | string | 1.12.0 | + +```{note} +Catalog-level configurations (`spark.sql.catalog.<catalog>.*`) are captured when the catalog is +initialized, so they must be present at the Spark application bootstrap (in `spark-defaults.conf` +or via `--conf`). Setting them through `SET` after the catalog has been created does not take Review Comment: Good catch, the V2 catalog is lazily initialized and session-isolated, so configs apply as long as they're set before first access. Only the Kerberized cluster mode (no keytab) genuinely needs `metastore.uris` declared at bootstrap. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
