# tDataMasking properties for Apache Spark Batch

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

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

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

## Basic settings

| Properties | Description |
| --- | --- |
| Schema and 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> <div><span>Information note</span><span>Remember:</span> When you select the <span>Dynamic</span> data type, remember                     that: <ul> <li>The data masking function applies to each data of the dynamic column.                           For example, if the columns are <kbd>name</kbd>,                              <kbd>address</kbd>, and <kbd>email</kbd>, the                           data masking function applies to each of these three data as separate                           data, not as a whole.</li> <li>If some data types from the dynamic column are incompatible with some                           data masking functions, the Job fails. For example, the <span>Email                              Masking</span> function is incompatible with the                              <kbd>Integer</kbd> data type.</li> <li>Some data masking functions validate the input data. When at least one                           data from a record cannot be masked, the record goes to the invalid                           output flow.</li> </ul></div> <div>The output schema of this component contains        read-only columns: <ul> <li> <span>TWEAK</span>: Is generated when the              <span>Use tweaks with FF1 Encryption</span> check box is            selected. This column contains the tweak necessary to decrypt the data.</li> <li> <span>ORIGINAL_MARK</span>: Identifies by              <span>true</span> or <span>false</span> if the record is an original record or a substitute            record respectively.</li> </ul> </div> </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 change and how to change<br>them:<br><br><br>Input Column: Select the column from<br>the input flow that contains the data to be masked.<br><br>The supported data types are:<br>Date, Double, Float, Integer, Long and String.<br><br>These<br>modifications are based on the function you select in the Function column.<br><br>Category: select a category of<br>masking functions from the list.<br><br><ul> <li> <span>Character Handling</span> </li> <li> <span>Data Handling</span> </li> <li> <span>Number Handling</span> </li> <li> <span>Bank Account                                                  Generation</span> </li> <li> <span>Data Generation</span> </li> <li> <span>Phone Number                                                  generation</span> </li> <li> <span>SSN Generation</span> </li> <li> <span>Bank Account Masking</span> </li> <li> <span>Address Masking</span> </li> <li> <span>Email Masking</span> </li> <li> <span>Credit Card Masking</span> </li> <li> <span>Phone Masking</span> </li> <li> <span>SSN Masking</span> </li> <li> <span>Set to null</span> </li> </ul><br><br><br>Function: Select the function that<br>will hide or obfuscate the original data with substitutes. For example, you can replace<br>digits or letters with the substitute of your choice, replace values with synonyms from<br>an index file or nullify values.<br><br>The functions you can<br>select from the Function list depend<br>on the data type of the input column.<br><br>For example, if the column type<br>is Long, you can use the Numeric variance function. If the column type is String, the Numeric<br>variance function will not be available. Also, the Function list for a Date column is date-specific, it allows you to decide the type of<br>modification you want to do on date values.<br><br><br>Method: Select the Basic method or one FF1 algorithm (Format-Preserving<br>Encryption (FPE)), FF1 with AES or FF1 with SHA-2:<br><br>The Basic method is the default<br>algorithm.<br><br>Information noteNote: As the masking methods are stronger, it is recommended to use the FF1<br>algorithms rather than the Basic method.<br><br>The FF1 with AES method is based<br>on the Advanced Encryption Standard in CBC mode. The FF1 with<br>SHA-2 method depends on the secure hash function HMAC-256.<br><br>Information noteNote: Java 8u161 is the minimum<br>required version to use the FF1 with AES method.<br>To be able to use this FPE method with Java versions earlier than 8u161, download the<br>Java Cryptography Extension (JCE) unlimited strength jurisdiction policy files from<br>Oracle website.<br><br>The FF1 with AES and<br>FF1 with SHA-2 methods require a password to<br>be specified in the Password or 256-bit key for FF1 methods<br>field of the Advanced settings to generate unique<br>masked values.<br><br>The Alphabet list is only available for<br>functions that use Format-Preserving Encryption algorithms.<br><br>When using the Character<br>handling functions, such as Replace all,<br>Replace characters between two positions,<br>Replace all digits with FPE methods, you must select<br>an alphabet.<br><br>Characters that<br>belong to the selected alphabets are masked with characters from the same character type<br>within the selected alphabet.<br><br>When selecting the Best guess alphabet, masked values contain characters<br>from all alphabets represented in the input values. Best<br>guess is the default alphabet.<br><br>Any unrecognized character is copied to the output as is.<br><br><br>Extra Parameter: This field is used<br>by some of the functions, it will be disabled when not applicable. When applicable,<br>enter a number or a letter to decide the behavior of the function you have<br>selected.<br><br>When you set Function to<br>Generate from file/list, define the file path in Extra<br>Parameter. Set the file path as follows:<br><br><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 index is on a cluster: <span>hdfs://hdpnameservice1/file path</span>.            </li> </ul><br><br><br>Keep format: this function is only<br>used on Strings. Select this check box to keep the input format when using the<br>Generate account number and keep original<br>country, Generate credit card<br>number and keep original bank, Bank Account<br>Masking, Credit Card Masking,<br>Phone Masking and SSN Masking functions or categories. That is to say, if there are<br>spaces, dots ('.'), hyphens ('-') or slashes ('/') in the input, those characters are<br>kept in the output. If you select this check box when using Phone Masking functions, the characters that are not numbers from the<br>input are copied to the output as is. |

## Advanced settings

| Properties | Description |
| --- | --- |
| FF1 settings | Password or 256-bit key for FF1 methods: Set the password or secret key required for the<br>FF1 with AES and FF1<br>with SHA-2 methods to generate unique masked<br>values. If the password is not set, a random password is created<br>at each Job execution. When using the FF1 with<br>AES and FF1 with SHA-2<br>methods and a password, the seed from the Seed for<br>random generator field is not<br>used.<br><br><br>You can get the 256-bit key using:<br><br><ul> <li>Online tools</li> <li>OpenSSL: <span>openssl rand -base64 32</span> </li> </ul><br><br><br>Use tweaks with FF1 Encryption: Select this check box to use tweaks. A unique tweak is<br>generated for each record and applies to all data of a record.<br>If bijective masking is necessary, do not use this feature.<br>For more information about tweaks, see the [data masking functions](https://help.qlik.com/talend/r/en-US/8.0/components/data-privacy/data-masking-functions-in-masking-components).<br><br><br>Use a column containing the tweaks: Available when Use tweaks with FF1<br>Encryption check box is selected. Select this check box to<br>use an input column as the input for tweaks which must be 32 digit<br>hexadecimal strings.<br><br><br>Column containing the tweaks: Available when the Use a column<br>containing the tweaks check box is selected. Select the<br>column that contains the tweaks.<br><br><br><br>Key derivation function<br>: Select the key derivation function. Jobs created from<br>Talend Studio 8.0 R2022-04 run using PBKDF2 with 300,000<br>iterations.<br><br>When you import a Job prior to Talend Studio 8.0 R2022-04, you can run the Job using 300,000 iterations. The results will<br>be different than using 65,536 iterations. |
| Seed for random 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>This field is of Long type. The value range is [-2^63^, 2^63^-1].<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 masking<br>function applies:<br><br><ul> <li>The functions that do not validate the input data (The Character                           Handling functions, the Address Masking function, and the Numeric                           variance function) return the default value depending on the data type:<ul> <li>String: Empty output.</li> <li>Numeric input: <samp>0</samp>.</li> </ul> <p>For the Date variance function, the output date is the one on which                              the Job was run.</p> </li> <li>The generation functions generate a new value. The data are sent to the                           main flow.</li> <li>The validation functions (Email Masking, Phone Masking, Credit Card                           Masking, SSN Masking, and Bank Account Masking) cannot validate the                           value. The data are sent to the "Invalid" output flow.</li> </ul><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 flow | This check box is selected by default.<br><br><ul> <li>Selected: When the data can be masked, 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>The data are considered invalid when:<br><br><ul> <li>The format of the SSN, phone number or email address is incorrect,                        regardless of the <span>Method</span> used.</li> <li>They do not comply to the <a href="https://help.qlik.com/talend/r/en-US/8.0/components/data-privacy/data-masking-functions-in-masking-components"><span>FF1 with AES</span> and                              <span>FF1 with SHA-2</span> methods</a>.</li> </ul> |

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