# tManagePartitions

Allows you to visually define how an input dataset is partitioned.

The tManagePartitions splits the input dataset into a given number of partitions.

## tManagePartitions properties for Apache Spark Batch

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

The Spark Batch tManagePartitions component belongs to the Processing family.

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

## Basic settings

| Properties | Description |
| --- | --- |
| Number of partitions | Enter the number of partitions you want to split the input dataset up<br>into. |
| Partitioning strategy | Select the partitioning strategy you want to apply to the dataset from the<br>drop-down list:<br><br><ul> <li> <span>Coalesce</span>: reduces the number of partitions.</li> <li> <span>Repartition</span>: increases or decrease the number of                        partitions.</li> <li> <span>Auto</span>: calculates the better strategy to apply.</li> </ul> |
| Partitioning with range | Select this check box to apply a partition on the dataset based on a range<br>of the column values. You need to specify at least a column to use this<br>parameter. |
| Use custom partitioner | Select this check box to use a Spark partitioner you need to import from<br>outside Talend Studio.<br>For example, a partitioner you have developed by yourself. In this situation, you<br>need to give the following information:<br><br><ul> <li> <p> <span>Fully qualified class name</span>: enter                           the fully qualified class name of the partitioner to be imported.</p> </li> <li> <p> <span>JAR name</span>: click the <span>[+]</span> button as many time as needed to add                           the same number of rows. In each row, click the <span>[...]</span> button to import the jar file                           containing this partitioner class and its dependent jar files.</p> </li> </ul><br><br>This parameter is only available when you select<br>Repartition from the Partitioning<br>strategy drop-down list. |
| Use column(s) as key(s) for partitioning | Select the column you want to use as key for partitioning.<br><br>This parameter<br>is only available when you select Repartition from the<br>Partitioning strategy drop-down list. This parameter<br>is not available when you select the Use a custom<br>partitioner check box. |
| Sort within partitions | Select this check box to sort the records in each partition:<br><br><ul> <li> <p> <span>Natural order</span>: keys are sorted in                           their natural order, for example, in the alphabetical order. </p> </li> <li> <p> <span>Custom comparator</span>: this allows you                           to use a custom program to sort the keys. </p> <p>You need to enter the fully qualified class name of the                           comparator to be imported in the <span>Fully                              qualified class name</span> field and add the JAR files to be                           loaded in the <span>JAR name</span> table.</p> </li> </ul><br><br>This feature is useful when a partition contains several distinct key<br>values. |

## Global Variables

| Variables | Description |
| --- | --- |
| ERROR\_MESSAGE | The error message generated by the component when an error<br>occurs. This is an After variable and it returns a string. |

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