# tPatternMasking 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 tPatternMasking running in the Spark Structured Streaming Job framework.

The Spark Structured Streaming tPatternMasking 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 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>Column to mask:<br>Select the column from the input flow for which you want to generate<br>similar data by modifying its values.<br><br>You can mask data from different columns but you need to<br>follow the order of the fields you want to mask.<br><br>Each column is processed sequentially, meaning that data masking<br>operations will be performed on the data from the first column, the<br>second column, and so on.<br><br>In a colum, each data field is a fixed length field, except the last data<br>field.<br><br>For fixed length fields, each value must contain the same number of<br>characters, for example: "30001,30002,30003" or<br>"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 contain the same<br>number of characters, for example:<br>"30001,300023,30003" or<br>"FR,ENG".<br><br>Field type: Select 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 masked 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> <p>Each value must contain the same number of characters. For                                              example: <kbd>"30001,30002,30003"</kbd> or                                                  <kbd>"FR,EN"</kbd>.</p> </li> <li> <span>Enumeration from                                              file</span>: When selected, set the path to the CSV                                          file containing a list of values to be used for masking data in                                          the <span>Path</span> field. The file                                          must contain one value per row, each value must be unique and                                          the values must have the same number of characters.<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> <p>Paths to folders are                                              not supported.</p> </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, Path,<br>Range and Date Range,<br>values must be enclosed in double 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. |

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