# tSqlRow properties for Apache Spark Batch

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

The Spark Batch tSqlRow component belongs to the Processing 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 |
| --- | --- |
| 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><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>When the schema to be reused has default values that are<br>integers or functions, ensure that these default values are not enclosed within<br>quotation marks. If they are, you must remove the quotation marks manually.<br><br>For more information, see [Retrieving table schemas](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/retrieving-table-schemas?tocId=_C1~eFOlN~GM_JR2qkBYZg).<br><br>Click Edit schema to make changes to<br>the schema. If you make changes, the schema automatically becomes built-in.<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><br><br>This component offers the advantage of the<br>dynamic schema feature. This allows you to retrieve unknown columns from source<br>files or to copy batches of columns from a source without mapping each column<br>individually. For further information about dynamic schemas, see [Dynamic schema](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/dynamic-schema).<br><br>This<br>dynamic schema feature is designed for the purpose of retrieving unknown columns of a<br>table and is recommended to be used for this purpose only; it is not recommended for the<br>use of creating tables.<br><br>With dynamic schema, you can read and query complex schema in Parquet files<br>(containing struct and map for example) with<br>the tSQLRow component using Spark SQL. |
| SQL context | Select the query languages you want tSqlRow to use.<br><br><ul> <li> <p><span>SQL Spark Context</span>: the Spark native query language.</p> </li> <li> <p><span>SQL Hive Context</span>: the Hive query language supported by Spark.</p> <p>In <span>SQL Hive Context</span>, <span>tSqlRow</span> does not allow you to use Hive metastore. If you need to read or write data to Hive metastore, use <span>tHiveInput</span> or <span>tHiveOutput</span> instead and in this situation, you need to design your Job differently.</p> <p>For further information about the Spark supported Hive query statements, see <a href="https://spark.apache.org/docs/2.3.0/sql-programming-guide.html#supported-hive-features" target="_blank">Supported Hive features</a>.</p> </li> <li> <div><span>Spark Session</span>: the Spark Session query language.<div><div><a href="https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Introduction/feature-preview-program-overview.htm">Preview</a></div> <div><span>Information note</span><span>Note:</span> Select <span>Spark Session</span> when                                 using the Databricks Serverless runtime. This option is required                                 for compatibility with Databricks Serverless on AWS and                                 Azure.</div> </div></div> </li> </ul> |
| Query | Enter your query paying particularly attention to properly sequence<br>the fields in order to match the schema definition.<br><br>The tSqlRow<br>component uses the label of its input link to name the registered table that stores the<br>datasets from the same input link. For example, if a input link is labeled to *row1*, this *row1* is automatically<br>the name of the table in which you can perform queries. |

## Advanced settings

| Properties | Description |
| --- | --- |
| Register UDF jars | Add the Spark SQL or Hive SQL UDF (user-defined function) jars you want tSqlRow to use. If you do not want to call your UDF using its<br>FQCN (Fully-Qualified Class Name), you must define a function alias for this UDF in the<br>Temporary UDF<br>functions table and use this alias. It is recommended to use the alias<br>approach, as an alias is often more practical to use to call a UDF from the query.<br><br>Once you add one row to this table, click it to display the [...] button and then click this<br>button to display the jar import wizard. Through this wizard, import the UDF jar files you<br>want to use. |
| Temporary UDF functions | Complete this table to give each imported UDF class a temporary function name to be used<br>in the query in tSqlRow.<br><br>If you have selected SQL Spark Context from the SQL context list, the UDF output<br>type column is displayed. In this column, you need to select the data type of the<br>output of the Spark SQL UDF to be used. |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | This component is used as an intermediate step.<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.<br><br>Note that in this documentation, unless otherwise explicitly stated, a<br>scenario presents only Standard Jobs, that is to<br>say traditional<br>Talend<br>data integration Jobs. |
| Spark Connection | In the Spark<br>Configuration tab in the Run<br>view, define the connection to a given Spark cluster for the whole Job. In<br>addition, since the Job expects its dependent jar files for execution, you must<br>specify the directory in the file system to which these jar files are<br>transferred so that Spark can access these files:<br><br><ul> <li> <div> <span>Yarn mode</span> (Yarn client or Yarn cluster):<ul> <li> <p>When using Google Dataproc, specify a bucket in the                                            <span>Google Storage staging bucket</span>                                        field in the <span>Spark configuration</span>                                        tab.</p> </li> <li> <p>When using HDInsight, specify the blob to be used for Job                                        deployment in the <span>Windows Azure Storage                                            configuration</span> area in the <span>Spark                                            configuration</span> tab.</p> </li> <li>When using Altus, specify the S3 bucket or the Azure                                    Data Lake Storage for Job deployment in the <span>Spark                                        configuration</span> tab.</li> <li> <p>When using on-premises distributions, use                                        the configuration component corresponding to the file system                                        your cluster is using. Typically, this system is HDFS and so                                        use <a href="https://help.qlik.com/talend/r/en-US/8.0/components/hdfs/thdfsconfiguration">tHDFSConfiguration</a>.</p> </li> </ul> </div> </li> <li> <p> <span>Standalone mode</span>: use the                            configuration component corresponding to the file system your cluster is                            using, such as <a href="https://help.qlik.com/talend/r/en-US/8.0/components/hdfs/thdfsconfiguration-properties-for-apache-spark-batch">tHDFSConfiguration Apache Spark Batch</a> or <a href="https://help.qlik.com/talend/r/en-US/8.0/components/amazon-s3/ts3configuration-properties-for-apache-spark-batch">tS3Configuration Apache Spark Batch</a>.</p> <p>If you are using Databricks without any configuration component present                            in your Job, your business data is written directly in DBFS (Databricks                            Filesystem).</p> </li> </ul><br><br>This connection is effective on a per-Job basis. |