You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "ayushtkn (via GitHub)" <gi...@apache.org> on 2025/01/03 05:55:37 UTC

Re: [PR] HDDS-11962. [Docs] Hive Integration [ozone]

ayushtkn commented on code in PR #7596:
URL: https://github.com/apache/ozone/pull/7596#discussion_r1901487538


##########
hadoop-hdds/docs/content/integration/Hive.md:
##########
@@ -0,0 +1,170 @@
+---
+title: Hive
+weight: 4
+menu:
+   main:
+      parent: "Application Integrations"
+---
+<!---
+  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.
+-->
+
+# Overview
+Apache Hive has supported Apache Ozone since Hive 4.0. To enable Hive to work with Ozone paths, ensure that the `ozone-filesystem-hadoop3` JAR is added to the Hive classpath.
+
+# Supported Access Protocols
+
+Hive supports the following protocols for accessing Ozone data:
+
+* ofs
+* o3fs
+* s3a
+
+# Supported Replication Types
+
+Hive is compatible with Ozone buckets configured with either:
+
+* RATIS (Replication)
+* Erasure Coding
+
+# Accessing Ozone Data in Hive
+
+Hive provides two methods to interact with data in Ozone:
+
+* Managed Tables
+* External Tables
+
+## Managed Tables
+### Configuring the Hive Warehouse Directory in Ozone
+To store managed tables in Ozone, update the following properties in the `hive-site.xml` configuration file:
+
+```xml
+<property>
+  <name>hive.metastore.warehouse.dir</name>
+  <value>ofs://ozone1/vol1/bucket1/warehouse/</value>
+</property>
+```
+
+### Creating a Managed Table
+You can create a managed table with a standard `CREATE TABLE` statement:
+
+```sql
+CREATE TABLE myTable (
+    id INT,
+    name STRING
+);
+```
+
+### Loading Data into a Managed Table
+Data can be loaded into a Hive table from an Ozone location:
+
+```sql
+LOAD DATA INPATH 'ofs://ozone1/vol1/bucket1/table.csv' INTO TABLE myTable;
+```
+
+### Specifying a Custom Ozone Path
+You can define a custom Ozone path for a database using the `MANAGEDLOCATION` clause:
+
+```sql
+CREATE DATABASE d1 MANAGEDLOCATION 'ofs://ozone1/vol1/bucket1/data';
+```
+
+Tables created in the database d1 will be stored under the specified path:
+`ofs://ozone1/vol1/bucket1/data`
+
+### Verifying the Ozone Path
+You can confirm that Hive references the correct Ozone path using:
+
+```sql
+SHOW CREATE DATABASE d1;
+```
+
+Output Example:
+
+```text
++----------------------------------------------------+
+|                   createdb_stmt                    |
++----------------------------------------------------+
+| CREATE DATABASE `d1`                               |
+| LOCATION                                           |
+|   'ofs://ozone1/vol1/bucket1/external/d1.db'       |
+| MANAGEDLOCATION                                    |
+|   'ofs://ozone1/vol1/bucket1/data'                 |
++----------------------------------------------------+
+```
+
+## External Tables
+
+Hive allows the creation of external tables to query existing data stored in Ozone.
+
+### Creating an External Table
+```sql
+CREATE EXTERNAL TABLE external_table (
+    id INT,
+    name STRING
+)
+LOCATION 'ofs://ozone1/vol1/bucket1/table1';
+```
+
+* With external tables, the data is expected to be created and managed by another tool.
+* Hive queries the data as-is.
+* The metadata is stored under the external warehouse directory.
+* Note: Dropping an external table in Hive does not delete the associated data.
+
+You can also have the metadata for the external tables stored in Ozone too by applying the following configuration in the `hive-site.xml` file:

Review Comment:
   Metadata is stored in HMS. only the Data is stored Storage layer, the below config will configure to store the data for External table by default in the specified path, if the path isn't explicitly specified while creating the external table.



##########
hadoop-hdds/docs/content/integration/Hive.md:
##########
@@ -0,0 +1,170 @@
+---
+title: Hive
+weight: 4
+menu:
+   main:
+      parent: "Application Integrations"
+---
+<!---
+  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.
+-->
+
+# Overview
+Apache Hive has supported Apache Ozone since Hive 4.0. To enable Hive to work with Ozone paths, ensure that the `ozone-filesystem-hadoop3` JAR is added to the Hive classpath.
+
+# Supported Access Protocols
+
+Hive supports the following protocols for accessing Ozone data:
+
+* ofs
+* o3fs
+* s3a
+
+# Supported Replication Types
+
+Hive is compatible with Ozone buckets configured with either:
+
+* RATIS (Replication)
+* Erasure Coding
+
+# Accessing Ozone Data in Hive
+
+Hive provides two methods to interact with data in Ozone:
+
+* Managed Tables
+* External Tables
+
+## Managed Tables
+### Configuring the Hive Warehouse Directory in Ozone
+To store managed tables in Ozone, update the following properties in the `hive-site.xml` configuration file:
+
+```xml
+<property>
+  <name>hive.metastore.warehouse.dir</name>
+  <value>ofs://ozone1/vol1/bucket1/warehouse/</value>
+</property>
+```
+
+### Creating a Managed Table
+You can create a managed table with a standard `CREATE TABLE` statement:
+
+```sql
+CREATE TABLE myTable (
+    id INT,
+    name STRING
+);
+```
+
+### Loading Data into a Managed Table
+Data can be loaded into a Hive table from an Ozone location:
+
+```sql
+LOAD DATA INPATH 'ofs://ozone1/vol1/bucket1/table.csv' INTO TABLE myTable;
+```
+
+### Specifying a Custom Ozone Path
+You can define a custom Ozone path for a database using the `MANAGEDLOCATION` clause:
+
+```sql
+CREATE DATABASE d1 MANAGEDLOCATION 'ofs://ozone1/vol1/bucket1/data';
+```
+
+Tables created in the database d1 will be stored under the specified path:
+`ofs://ozone1/vol1/bucket1/data`
+
+### Verifying the Ozone Path
+You can confirm that Hive references the correct Ozone path using:
+
+```sql
+SHOW CREATE DATABASE d1;
+```
+
+Output Example:
+
+```text
++----------------------------------------------------+
+|                   createdb_stmt                    |
++----------------------------------------------------+
+| CREATE DATABASE `d1`                               |
+| LOCATION                                           |
+|   'ofs://ozone1/vol1/bucket1/external/d1.db'       |
+| MANAGEDLOCATION                                    |
+|   'ofs://ozone1/vol1/bucket1/data'                 |
++----------------------------------------------------+
+```
+
+## External Tables
+
+Hive allows the creation of external tables to query existing data stored in Ozone.
+
+### Creating an External Table
+```sql
+CREATE EXTERNAL TABLE external_table (
+    id INT,
+    name STRING
+)
+LOCATION 'ofs://ozone1/vol1/bucket1/table1';
+```
+
+* With external tables, the data is expected to be created and managed by another tool.
+* Hive queries the data as-is.
+* The metadata is stored under the external warehouse directory.

Review Comment:
   data is stored in the external warehouse directory, if no LOCATION is specified when creating an external table, maybe if not needed we can drop the explanation of external table itself, that goes bit into Hive scope



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org