# tPatternUnmasking properties for Apache Spark Batch

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

The Spark Batch tPatternUnmasking component belongs to the Data Quality family.

## Basic settings

| Properties | Description |
| --- | --- |
| Schema and<br>Edit Schema | <ul> <li> <p>A schema is a row description. It defines the number of fields            (columns) to be processed and passed on to the next component. When you create a Spark            Job, avoid the reserved word <kbd>line</kbd> when naming the            fields.</p> <p>Click <span>Sync        columns</span> to retrieve the schema from the previous component connected in the      Job.</p> <p>Click <span>Edit        schema</span> to make changes to the schema. If the current schema is of the <span>Repository</span> type, three options are available:</p> <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> <p>The output schema of this component							contains one read-only column, ORIGINAL_MARK. This column identifies by								<span>true</span> or <span>false</span> if the record is an							masked or and original respectively.</p> </li> <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> |
| Modifications | Define in the table what fields to unmask and how to<br>unmask them:<br><br>Use the same settings for the Field<br>type, Values,<br>Path, Range and<br>Date Range columns as the ones used for<br>masking the input data with the tPatternMasking<br>component.<br><br><br>Column to unmask:<br>Select the column from the input flow that contains the data to be<br>unmasked.<br><br>Each column is processed sequentially, meaning that data<br>unmasking operations will be performed on the data from the first<br>column, the second column, and so on.<br><br>In a colum, each data field is a fixed length field,<br>except the last data field.<br><br>For fixed length fields, each value must contain the<br>same number of characters, for example: "30001,30002,30003" or "FR,EN".<br><br>In a column, the last Enumeration or Enumeration<br>from file data field is a variable length field.<br><br>For variable length fields, each value might not always<br>contain the same number of characters, for example: "30001,300023,30003" or "FR,ENG".<br><br>Field type: Select<br>the field type the data belongs to.<br><br><ul> <li> <p> <span>Interval</span>: When selected, set a range of										numeric values used for masking purposes in the <span>Range</span> field, using the										following syntax: <kbd>"&lt;min&gt;,&lt;max&gt;"</kbd>.</p> <p>The number of unmasked characters from the										input data corresponds to the number of characters of the										maximum value.</p> <p>For example, <kbd>"1,999"</kbd> will be interpreted as <kbd>"001,999"</kbd>, which means that										three characters from the input data will be masked by a										value randomly selected from the defined range of										values.</p> </li> <li> <p> <span>Enumeration</span>: When selected, enter a										comma-separated list of values to be used for masking data										in the <span>Values</span> field,										using the following syntax: <kbd>"value1,value2,value3"</kbd>.</p> </li> <li> <span>Enumeration from file</span>: When									selected, set the path to the CSV file containing a list of									values used for masking data in the <span>Path</span> field. The file must contain one value per									row and each value must be unique.                           <div>You can select a file on:<ul> <li>The local system.</li> <li>Amazon S3, in local Spark mode or connected to EMR, using                            <span>tS3Configuration</span>. S3N and S3A file                        systems are supported.</li> <li>Azure Blob Storage, in local Spark mode or connected to Azure HDInsight or                  Databricks, using <span>tAzureFSConfiguration</span>. </li> <li>Azure Data Lake Storage, in local Spark mode or connected to Azure HDInsight,                  using <span>tAzureFSConfiguration</span>.</li> <li>Google Cloud Storage, in local Spark mode or connected to Dataproc, using                     <span>tGSConfiguration</span>.</li> <li>HDFS, in local Spark mode or connected to Azure HDInsight, using                     <span>tHDFSConfiguration</span>.</li> </ul> </div> <div>Set the file path as follows:<ul> <li>In local mode:<ul> <li>Apache Spark 3.1 and earlier: <span>prefix://file path</span> or                        <span>file:///file path</span>.</li> <li>Apache Spark 3.2 and later: <span>file:///file path</span>.</li> </ul></li> <li>In Standalone and Yarn modes: <span>prefix://file path</span>.</li> <li>If the file is on a cluster, <span>hdfs://hdpnameservice1/file               path</span>.</li> <li>If the file is on Azure Blob Storage and you are connected to Azure HDInsight or               Databricks,                  <span>wasbs://&lt;container_name&gt;@&lt;storage_account_name&gt;.blob.core.windows.net/&lt;folder&gt;/&lt;file_name&gt;"</span>               .</li> </ul> </div> </li> <li> <p> <span>Date pattern											(YYYYMMDD)</span>: When selected, set a range of										years in the <span>Date											Range</span> field, using the following syntax:											<kbd>"&lt;min_year&gt;,&lt;max_year&gt;"</kbd>.</p> <p>Years can only have four digits, for example:											<kbd>"1900,2100"</kbd>.</p> <p>The input dates to be masked must follow the										YYYYMMDD pattern, for example: <kbd>20180101</kbd>.</p> <p>For example, if the input date is <kbd>20180101</kbd> and the value in										the <span>Date Range</span> is											<kbd>"1900,2100"</kbd>,											<span>19221221</span> could be the										output date.</p> </li> </ul><br><br>In the Values,<br>Path, Range and Date Range, values must be enclosed in double<br>quotes.<br><br>When the input data is invalid, meaning that a value<br>does not match the pattern defined in the component, the generated value is<br>null. |

## Advanced settings

| Properties | Description |
| --- | --- |
| Method | From this list, select the Format-Preserving Encryption<br>(FPE) algorithm that was used to mask data, FF1 with AES or FF1 with<br>SHA-2:<br><br>The FF1 with AES<br>method is based on the Advanced Encryption Standard in CBC mode. The<br>FF1 with SHA-2 method depends<br>on the secure hash function HMAC-256.<br><br>Java 8u161 is the minimum required version to use the<br>FF1 with AES method. To be<br>able to use this FPE method with Java versions earlier than 8u161,<br>download the Java Cryptography Extension (JCE) unlimited strength<br>jurisdiction policy files from Oracle website. |
| FF1 settings | Password or 256-bit key for FF1 methods: To unmask data,<br>the FF1 with AES and FF1 with SHA-2 methods require the password or secret key<br>specified in Password or 256-bit key for FF1 methods<br>when the data was masked with the tPatternMasking component.<br><br><br>Use tweaks: If tweaks have been generated while masking the data,<br>select this check box. When selected, the Column containing<br>tweaks list is displayed. A tweak allows to unmask all<br>data of a record.<br><br><br>Column containing the tweaks: Available when the Use tweaks<br>check box is selected. Select the column that contains the tweaks. If you do<br>not see it, make sure you have declared in the input component the tweaks<br>generated by the masking component.<br><br><br><br>Key derivation function<br>: Select the same key derivation function as to mask<br>the data. By default, PBKDF2 with 300,000 iterations<br>is selected. |
| Seed for random<br>generator | Set a random number if you want to generate the same sample of<br>substitute data in each execution of the Job. The seed is not set by default.<br><br>If you do not set the seed, the component<br>creates a new random seed for each Job execution. Repeating the execution with a<br>different seed will result in a different sample being generated. |
| Encoding | Select the encoding from the list or select Custom and define it manually. If you select Custom and leave the field empty, the supported<br>encodings depend on the JVM that you are using. This field is compulsory for the file<br>encoding. |
| Output the original row | Select this check box to output original data rows in addition to the<br>substitute data. Outputting both the original and substitute data can be useful in debug<br>or test processes. |
| Null input returns null | This check box is selected by<br>default. When selected, the component outputs null when<br>input values are null.<br><br>When cleared, and when the input data is null, the input data<br>are sent to the "Invalid" output flow.<br><br>From Talend Studio<br>R2024-08 onwards, when Null input returns null is selected<br>and the input data is null, the masking function is not applied,<br>null is returned and the input data are sent to the main flow. |
| Empty input returns an empty output | When this check box is selected, empty values are left unchanged in<br>the output data. Otherwise, the selected functions are applied to the input<br>data. |
| Send invalid data to "Invalid" output<br>flow | This check box is selected by default.<br><br><ul> <li>Selected: When the data can be unmasked, they are sent to the main flow.                        Otherwise, the data are sent to the "Invalid" output flow.</li> <li>Cleared: The data are sent to the main flow.</li> </ul><br><br><br>Invalid data are any values that do not match the pattern. |

## 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<br>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. |