# tDataMasking properties for Apache Spark Structured Streaming

[Preview](https://help.qlik.com/en-US/cloud-services/Subsystems/Hub/Content/Sense_Hub/Introduction/feature-preview-program-overview.htm)

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

The Spark Structured Streaming tDataMasking component belongs to the Data Quality family.

This component is supported on Local Spark 3.5.x and Databricks/EMR with Spark 3.x.

Information noteNote: This component does not support dynamic schema.

This component is available in Talend Real-Time Big Data Platform and Talend Data Fabric.

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

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | This component is used as an intermediate step.<br><br>This component, along with the Spark Structured Streaming component Palette it belongs to,<br>appears only when you are creating a Spark Structured Streaming Job. |
| Spark Connection | You need to use the Structured Streaming Configuration<br>tab in the Run view to define the connection to a Spark cluster for<br>the whole Job.<br><br>This connection is effective on a per-Job basis. |