# tHiveWarehouseOutput

Connects to a given Hive database and writes the received data into a given Hive table or a directory in HDFS using Hive Warehouse Connector.

Hive Warehouse Connector supports Hive internal tables which allow you to access ACID table data from Spark with Apache Hive 3 tables.

This component is not shipped with your Talend Studio by default. You need to install it using the Feature Manager. For more information, see [Installing features using the Feature Manager](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/install-features-to-talend-studio).

## tHiveWarehouseOutput properties for Apache Spark Batch

These properties are used to configure tHiveWarehouseOutput running in the Spark Batch Job framework.

The Spark Batch tHiveWarehouseOutput component belongs to the Storage family.

The component in this framework is available in all subscription-based Talend products with Big Data and Talend Data Fabric.

## Basic settings

| Properties | Description |
| --- | --- |
| Property Type | Select the way the connection details<br>will be set.<br><br><ul> <li> <p> <span>Built-In</span>: The connection details will be set                                locally for this component. You need to specify the values for all                                related connection properties manually.</p> </li> <li> <p> <span>Repository</span>: The connection details stored                                centrally in <span><span>Repository</span><abbr> &gt; </abbr><span>Metadata</span></span> will be reused by this component. </p> <p>You need to click                                the <span>[...]</span> button next to it and in the pop-up                                    <span>Repository Content</span> dialog box, select the                                connection details to be reused, and all related connection                                properties will be automatically filled in.</p> </li> </ul> |
| Hive Storage Configuration | Select the tHiveWarehouseConfiguration component<br>from which you want Spark to use the configuration details to connect to<br>Hive. |
| HDFS Storage Configuration | Select the tHDFSConfiguration component from which you want Spark to use the configuration<br>details to connect to a given HDFS system and transfer the dependent jar files to this HDFS<br>system. This field is relevant only when you are using an on-premises distribution. |
| Schema and Edit Schema | A schema is a row description. It defines the number of fields<br>(columns) to be processed and passed on to the next component. When you create a Spark<br>Job, avoid the reserved word line when naming the<br>fields.<br><br>Always use lowercase when naming a field because the processing behind the scene could force the field names to be lowercase.<br><br>Select the type of schema you want to use from the<br>Schema drop-down list:<br><br><ul> <li> <p> <span>Built-In</span>: You create and store the schema locally for this component                only.</p> </li> <li> <p> <span>Repository</span>: You have already created the schema and stored it in the                Repository. You can reuse it in various projects and Job designs.</p> </li> </ul><br><br>Click Edit<br>schema to make changes to the schema. If the current schema is of the Repository type, three options are available:<br><br><ul> <li> <p> <span>View schema</span>: choose this                option to view the schema only.</p> </li> <li> <p> <span>Change to built-in property</span>:                choose this option to change the schema to <span>Built-in</span> for local changes.</p> </li> <li> <p> <span>Update repository connection</span>:                choose this option to change the schema stored in the repository and decide whether                to propagate the changes to all the Jobs upon completion.</p> <p>If you just want to                propagate the changes to the current Job, you can select <span>No</span> upon completion and choose this schema metadata                again in the <span>Repository Content</span>                window.</p> </li> </ul> |
| Output source | Select the type of the output data you want<br>tHiveWarehouseOutput to change:<br><br><ul> <li> <p> <span>Hive table</span>: the <span>Database</span> field, the <span>Table name</span> field, the <span>Table format</span> list and the <span>Enable                            Hive partitions</span> check box are displayed. You need to enter                        the related information about the Hive database to be connected to and the                        Hive table you need to modify.</p> <p>By default, the format of the output data is JSON, but you can                        change it to ORC or Parquet by selecting the corresponding option from the                            <span>Table format</span> list.</p> </li> <li> <p> <span>ORC file</span>: the <span>Output folder</span> field is displayed and the                        Hive storage configuration list is deactivated, because the ORC file should                        be stored in your HDFS system hosting Hive. You need to enter the directory                        in which the output data is written.</p> </li> </ul> |
| Save mode | Select the type of changes you want to make regarding the target Hive<br>table:<br><br><ul> <li> <span>Create</span>: creates the target Hive table and                                writes data in this table.</li> <li> <span>Append</span>: adds data to an existing table.</li> <li> <span>Overwrite</span>: overwrites the data of the                                existing table.</li> <li> <span>Create if it does not exist</span>: creates a Hive table                        and adds data in it if there is no existing table. If there is an existing                        table, the input data is not saved.<p>This property is available when you                           have installed the 8.0.1-R2024-03 Studio Monthly or a later one provided                           by <span>Talend</span>. For more information, check with your administrator.</p> </li> </ul> |
| Enable Hive partitions | Select the Enable Hive partitions check box and in<br>the Partition keys table, define partitions for<br>the Hive table you are creating or changing. In the Partition<br>keys table, select columns from the input schema of<br>tHiveOutput to use as partition keys.<br><br>Bear in mind that:<br><br><ul> <li> <p>When the <span>Save mode</span> to be used is                                            <kbd>Append</kbd>, meaning that you are                                        adding data to an existing Hive table, the partition columns                                        you select in the <span>Partition keys</span>                                        table must be already partition keys of the Hive table to be                                        updated.</p> </li> <li> <p>A partitioned Hive table created by <span>tHiveOutput</span> can only be read                                        by <span>tHiveInput</span> due to Spark specific                                        limitations. If you need to read your partitioned table                                        through Hive itself, it is recommended to use                                            <span>tHiveRow</span> or                                            <span>tHiveCreateTable</span> in a Standard Job to                                        create this table and then use <span>tHiveOutput</span> to append data to it.</p> </li> <li> <p>Defining columns as partition keys does not alter your data                                        but only create subfolders using the partition keys and put                                        data in them.</p> </li> </ul> |

## Advanced settings

| Properties | Description |
| --- | --- |
| Sort columns alphabetically | Select this check box to sort the schema columns in the alphabetical order. If you leave this check box clear, these columns stick to the order defined in the schema editor. |

## Global Variables

| Variables | Description |
| --- | --- |
| Global Variables | ERROR\_MESSAGE: the error message generated by the<br>component when an error occurs. This is an After variable and it returns a string. This<br>variable functions only if the Die on error checkbox is<br>cleared, if the component has this checkbox.<br><br>A Flow variable functions during the execution of a component<br>while an After variable functions after the execution of the component.<br><br>To fill up a field or expression with a variable, press Ctrl+Space to access the variable list and choose the variable to use from<br>it.<br><br>For more information about variables, see [Using contexts and variables](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/contexts-and-variables). |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | This component is used as an end component and requires an input link.<br><br>This component should use a<br>tHiveWarehouseConfiguration component present<br>in the same Job to connect to Hive.<br><br>This component, along with the Spark Batch component Palette it belongs to,<br>appears only when you are creating a Spark Batch Job. |