# tGenKey properties for Apache Spark Batch

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

The Spark Batch tGenKey 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<br>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> </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> <li> <p>Click the import icon to import blocking keys from the match rules that are         defined and saved in the <span>Talend Studio</span>         repository.</p> <p>When you click the import icon, a <span>Match Rule            Selector</span> wizard is opened to help you import blocking keys from the match         rules listed in the <span>Talend Studio</span>         repository and use them in your Job.</p> <p>You can import blocking keys only from match rules that are defined with the VSR         algorithm and saved in the <span>Talend Studio</span>         repository. For further information, see <a href="https://help.qlik.com/talend/r/en-US/8.0/components/data-matching/importing-match-rules-from-studio-repository">Importing match rules from the Talend Studio repository</a> </p> </li> </ul> |
| Column | Select the columns from the main flow on which you want to define certain<br>algorithms to set the functional key.<br><br>Information noteNote: When you select a date column on which to apply an algorithm or a matching<br>algorithm, you can decide what to compare in the date format.<br><br>For example,<br>if you want to only compare the year in the date, in the component schema set the type<br>of the date column to Date and then enter "*yyyy*" in the Date Pattern field.<br>The component then converts the date format to a string according to the pattern defined<br>in the schema before starting a string comparison. |
| Pre-Algorithm | If required, select the relevant matching algorithm from the list:<br><br><br>Remove diacritical marks: removes any diacritical<br>mark.<br><br><br>Remove diacritical marks and lower case: removes any<br>diacritical mark and converts to lower case before generating the code of the column.<br><br><br>Remove diacritical marks and upper case: removes any<br>diacritical mark and converts to upper case before generating the code of the column.<br><br><br>Lower case: converts the field to lower case before<br>applying the key algorithm.<br><br><br>Upper case: converts the field to upper case before<br>applying the key algorithm.<br><br><br>Add left position character: enables you to add a<br>character to the left of the column.<br><br><br>Add right position character: enables you to add a<br>character to the right of the column. |
| Value | Set the algorithm value, where applicable. |
| Algorithm | Select the relevant algorithm from the list:<br><br><br>First character of each word: includes in the<br>functional key the first character of each word in the column. When using Japanese<br>characters in the input data, the input text should be tokenized. For more information,<br>see [tJapaneseTokenize](https://help.qlik.com/talend/r/en-US/8.0/components/text-standardization/tjapanesetokenize).<br><br><br>First N characters of each word: includes in the<br>functional key first N characters of each word in the column. When using Japanese characters<br>in the input data, the input text should be tokenized. For more information, see [tJapaneseTokenize](https://help.qlik.com/talend/r/en-US/8.0/components/text-standardization/tjapanesetokenize).<br><br><br>First N characters of the string: includes in the<br>functional key first N characters of the string.<br><br><br>Last N characters of the string: includes in the<br>functional key last N characters of the string.<br><br><br>First N consonants of the string: includes in the<br>functional key first N consonants of the string. Japanese and Chinese characters are not<br>supported.<br><br><br>First N vowels of the string: includes in the functional<br>key first N vowels of the string. Japanese and Chinese characters are not supported.<br><br><br>Pick characters: includes in the functional key the<br>characters located at a fixed position (corresponding to the set digital/range).<br><br><br>Exact: includes in the functional key the full<br>string.<br><br><br>Substring(a,b): includes in the functional key character<br>according to the set index.<br><br><br>Soundex code: generates a code according to a<br>standard English phonetic algorithm. This code represents the character string that will<br>be included in the functional key. Japanese and Chinese characters are not<br>supported.<br><br><br>Metaphone code: generates a code according to the<br>character pronunciation. This code represents the character string that will be included<br>in the functional key. Japanese and Chinese characters are not supported.<br><br><br>Double-metaphone code: generates a code according to<br>the character pronunciation using a new version of the Metaphone phonetic algorithm,<br>that produces more accurate results than the original algorithm. This code represents<br>the character string that will be included in the functional key. Japanese and Chinese<br>characters are not supported.<br><br>Fingerprint key: generates the functional key from a<br>string value through the following sequential process:<br><br><ol> <li> <p>remove leading and trailing whitespace,</p> </li> <li> <p>change all characters to their lowercase representation,</p> </li> <li> <p>remove all punctuation and control characters,</p> </li> <li> <p>split the string into whitespace-separated tokens,</p> </li> <li> <p>sort the tokens and remove duplicates,</p> </li> <li> <p>join the tokens back together,</p> <p>Because the string parts are sorted, the given order of tokens does not matter.                So, <em>Cruise, Tom</em> and <em>Tom Cruise</em> both end up                with a fingerprint <em>cruise tom</em> and therefore end up in the same                cluster.</p> </li> <li> <p>normalize extended western characters to their ASCII representation, for example                <em>gödel</em> to <em>godel</em>.</p> <p>This reproduce data entry mistakes performed when entering extended characters                with an ASCII-only keyboard. However, this procedure can also lead to false                positives, for example <em>gödel</em> and <em>godél</em>                would both end up with <em>godel</em> as their fingerprint but they are                likely to be different names. So this might work less effectively for datasets where                extended characters play substantial differentiation role.</p> </li> </ol><br><br>nGramkey: this algorithm is similar to the fingerPrintkey method described above. But instead of using<br>whitespace separated tokens, it uses n-grams, where the *n* can be<br>specified by the user. This method generates the functional key from a string value through<br>the following sequential process:<br><br><ol> <li> <p>change all characters to their lowercase representation,</p> </li> <li> <p>remove all punctuation and control characters,</p> </li> <li> <p>obtain all the string n-grams, </p> </li> <li> <p>sort the n-grams and remove duplicates,</p> </li> <li> <p>join the sorted n-grams back together,</p> </li> <li> <p>normalize extended western characters to their ASCII representation, for example                <em>gödel</em> to <em>godel</em>.</p> <p>For example, the 2-gram fingerprint of <em>Paris</em> is                <em>arispari</em> and the 1-gram fingerprint is                <em>aiprs</em>. </p> <p>The delivered implementation of this algorithm is 2-grams.</p> </li> </ol><br><br>Information noteNote:<br><br>If the column on which you want to use the nGramkey<br>algorithm can have data, with only *0* or *1*<br>characters, you must filter this data before generating the functional key. This way you<br>avoid potentially comparing records to each other that should not be match<br>candidates.<br><br><br>Cologne phonetics: a Soundex phonetic algorithm<br>optimized for the German language. It encodes a string into a Cologne phonetic value.<br>This code represents the character string that will be included in the functional key.<br>Japanese and Chinese characters are not supported. |
| Value | Set the algorithm value, where applicable.<br><br>If you do not set a value for the algorithms which need one, the Job runs with a<br>compilation error. |
| Post-Algorithm | If required, select the relevant matching algorithm from the list:<br><br><br>Use default value (string): enables you to choose a<br>string to replace null or empty data.<br><br><br>Add left position character: enables you to add a<br>character to the left of the column.<br><br><br>Add right position character: enables you to add a<br>character to the right of the column. |
| Value | Set the option value, where applicable. |
| Show help | Select this check box to display instructions on how to set algorithms/options<br>parameters. |

## Global Variables

| Variables | Description |
| --- | --- |
| Global Variables | ERROR\_MESSAGE: the error message generated by the<br>component when an error occurs. This is an After variable and it returns a string. This<br>variable functions only if the Die on error checkbox is<br>cleared, if the component has this checkbox.<br><br>A Flow variable functions during the execution of a component<br>while an After variable functions after the execution of the component.<br><br>To fill up a field or expression with a variable, press Ctrl+Space to access the variable list and choose the variable to use from<br>it.<br><br>For more information about variables, see [Using contexts and variables](https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/contexts-and-variables). |

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