# tCassandraOutput properties for Apache Spark Batch

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

The Spark Batch tCassandraOutput component belongs to the Databases family.

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

This component is not supported with Spark 4.0.x.

## Basic settings

| Properties | Description |
| --- | --- |
| Property type | Either Built-In or Repository.<br><br><br>Built-In: No property data stored centrally.<br><br><br>Repository: Select the repository file where the<br>properties are stored. |
| Sync columns | Click this button to retrieve schema from the previous component<br>connected in the Job. |
| Keyspace | Type in the name of the keyspace into which you want to write data. |
| Action on keyspace | Select the operation you want to perform on the keyspace to be used:<br><br><ul> <li> <p> <span>None</span>: No operation is carried out.</p> </li> <li> <p> <span>Drop and create keyspace</span>: The keyspace is removed                and created again.</p> </li> <li> <p> <span>Create keyspace</span>: The keyspace does not exist and                gets created.</p> </li> <li> <p> <span>Create keyspace if not exists</span>: A keyspace gets                created if it does not exist.</p> </li> <li> <p> <span>Drop keyspace if exists and create</span>: The keyspace                is removed if it already exists and created again.</p> </li> </ul> |
| Column family | Type in the name of the keyspace into which you want to write data. |
| Action on column family | Select the operation you want to perform on the column family to be used:<br><br><ul> <li> <p> <span>None</span>: no operation is carried out.</p> </li> <li> <p> <span>Create column family if not exists</span>: a column                family gets created if it does not exist.</p> </li> <li> <p> <span>Drop column family if exists and create</span>: the                column family is removed if it already exists and created again.</p> </li> <li> <p> <span>Truncate column family</span>: all data from the column                family is permanently removed.</p> </li> </ul><br><br>This list is available only when you have selected Update, Upsert or Insert from the Action on data drop-down<br>list. |
| Action on data | On the data of the table defined, you can perform:<br><br><ul> <li> <p> <span>Upsert</span>: insert the columns if they do not exist                or update the existing columns.</p> <p>With this action, the columns to be defined in the schema must use lower case in                their names, while the names you put in the <span>DB                    column</span> column of the schema must be identical with their equivalents                in the target table, including the letter cases.</p> </li> <li> <p> <span>Insert</span>: insert the columns if they do not exist.                This action also updates the existing ones.</p> </li> <li> <p> <span>Update</span>: update the existing columns or add the                columns that do not exist. This action does not support the <em>Counter</em> Cassandra data type.</p> </li> <li> <p> <span>Delete</span>: remove columns corresponding to the input                flow.</p> </li> </ul><br><br>For more advanced actions, use the Advanced settings<br>view. |
| 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>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> <p>The schema of this component does not support the <span>Object</span> type and the <span>List</span> type.</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> <p>When the schema to be reused has default values that are            integers or functions, ensure that these default values are not enclosed within            quotation marks. If they are, you must remove the quotation marks manually.</p> <p>For more information, see <a href="https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/retrieving-table-schemas?tocId=_C1~eFOlN~GM_JR2qkBYZg" target="_blank">Retrieving table schemas</a>.</p> </li> </ul> |

## Advanced settings

| Properties | Description |
| --- | --- |
| Configuration | Add the Cassandra properties you need to customize in upserting data into Cassandra.<br><br><ul> <li> <p>For example, if you need to define the Cassandra consistency level for                    writing, select the <em>output_consistency_level</em>                    property in the <span>Property name</span> column and enter                    the numeric level value in the <span>Value</span>                    column.</p> </li> </ul><br><br>The following list presents the numerical values you can put and the consistency levels<br>they signify:<br><br><ul> <li> <p>0: ANY,</p> </li> <li> <p>1: ONE,</p> </li> <li> <p>2: TWO,</p> </li> <li> <p>3: THREE,</p> </li> <li> <p>4: QUORUM,</p> </li> <li> <p>5: ALL,</p> </li> <li> <p>6: LOCAL_QUORUM,</p> </li> <li> <p>7: EACH_QUORUM,</p> </li> <li> <p>8: SERIAL,</p> </li> <li> <p>9: LOCAL_SERIAL,</p> </li> <li> <p>10: LOCAL_ONE</p> </li> </ul><br><br><br>For further details about each of the consistency policies, see Datastax<br>documentation about Cassandra.<br><br>When a row is added to the table, you need to click the new row in the Property name column to display the list of the available<br>properties and select the property or properties to be customized. For further information<br>about each of these properties, see the Tuning section in the following link: https://github.com/datastax/spark-cassandra-connector/blob/master/doc/5\_saving.md. |
| Use unlogged batch | Select this check box to handle data in batch but with Cassandra's UNLOGGED approach. This<br>feature is available to the following three actions: Insert, Update and Delete.<br><br>Then you need to configure how the batch mode works:<br><br><ul> <li> <p> <span>Batch size</span>: enter the number of lines in each                    batch to be processed. </p> </li> <li> <div> <span>Group batch method</span>: select how to group rows                    into batches:<ol> <li> <p> <span>Partition</span>: rows sharing the same                                partition keys are grouped.</p> </li> <li> <p> <span>Replica</span>: rows to be written to                                the same replica are grouped.</p> </li> <li> <p> <span>None</span>: rows are grouped randomly.                                This option is suitable for a single node Cassandra.</p> </li> </ol> </div> </li> <li> <p> <span>Cache batch group</span>: select this check box to                    load rows into memory before grouping them. This way, grouping is not impacted                    by the order of the rows.</p> <p>If you leave this check box clear, only successive rows that meet the same                    criteria are grouped.</p> </li> <li> <p> <span>Async execute</span>: select this check box if you                want <span>tCassandraOutput</span> to send batches in parallel.                If you leave it clear, <span>tCassandraOutput</span> waits for                the result of a batch before sending another batch to Cassandra.</p> </li> <li> <p> <span>Maximum number of batches executed in                        parallel</span>: once you have selected <span>Async                        execute</span>, enter the number of batches to be sent in parallel to                    Cassandra.</p> <p>This number should not be a negative number or 0 and it is also recommended                    not to use too large a value.</p> </li> </ul><br><br>The ideal situation to use batches with Cassandra is when a small number of tables must<br>synchronize the data to be inserted or updated.<br><br>In this UNLOGGED approach, the Job does not write batches into Cassandra's batchlog system<br>and thus avoids the performance issue incurred by this writing. For further information<br>about Cassandra BATCH statement and UNLOGGED approach, see [Batches](https://docs.datastax.com/en/dse/6.7/cql/cql/cql_reference/cql_commands/cqlBatch.html). |
| Insert if not exists | Select this check box to insert rows. This row insertion takes place only when they do not<br>exist in the target table.<br><br>This feature is available to the Insert action<br>only. |
| Delete if exists | Select this check box to remove from the target table only the rows that have the same<br>records in the incoming flow.<br><br>This feature is available only to the Delete<br>action. |
| Use TTL | Select this check box to write the TTL data in the target table. In the column list that<br>is displayed, you need to select the column to be used as the TTL column. The DB type of<br>this column must be Int.<br><br>This feature is available to the Insert action and the<br>Update action only. |
| Use Timestamp | Select this check box to write the timestamp data in the target table. In the column list<br>that is displayed, you need to select the column to be used to store the timestamp data. The<br>DB type of this column must be BigInt.<br><br>This feature is available to the following actions: Insert, Update and Delete. |
| IF condition | Add the condition to be met for the Update or the<br>Delete action to take place. This condition allows you<br>to be more precise about the columns to be updated or deleted. |
| Special assignment operation | Complete this table to construct advanced SET commands of Cassandra to make the Update action more specific. For example, add a record to the<br>beginning or a particular position of a given column.<br><br>In the Update column column of this table, you need to<br>select the column to be updated and then select the operations to be used from the Operation column. The following operations are available:<br><br><ul> <li> <p> <span>Append</span>: it adds incoming records to the end                    of the column to be updated. The Cassandra data types it can handle are Counter,                    List, Set and Map.</p> </li> <li> <p> <span>Prepend</span>: it adds incoming records to the                    beginning of the column to be updated. The only Cassandra data type it can                    handle is List.</p> </li> <li> <p> <span>Remove</span>: it removes records from the target                    table when the same records exist in the incoming flow. The Cassandra data types                    it can handle are Counter, List, Set and Map.</p> </li> <li> <p> <span>Assign based on position/key</span>: it adds records                    to a particular position of the column to be updated. The Cassandra data types                    it can handle are List and Map. </p> <p>Once you select this operation, the <span>Map key/list                        position</span> column becomes editable. From this column, you need to                    select the column to be used as reference to locate the position to be                    updated.</p> </li> </ul><br><br><br>For more details about these operations, see Datastax's related documentation<br>in http://docs.datastax.com/en/cql/3.1/cql/cql\_reference/update\_r.html?scroll=reference\_ds\_g4h\_qzq\_xj\_\_description\_unique\_34. |
| Row key in the List type | Select the column to be used to construct the WHERE clause of Cassandra to perform the<br>Update or the Delete<br>action on only selected rows. The column(s) to be used in this table should be from the set<br>of the Primary key columns of the Cassandra table. |
| Delete collection column based on<br>postion/key | Select the column to be used as reference to locate the particular row(s) to be<br>removed.<br><br>This feature is available only to the Delete<br>action. |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | This component is used as an end component and requires an input link.<br><br>This component should use one and only one tCassandraConfiguration component present in the same Job to connect to<br>Cassandra. More than one tCassandraConfiguration components<br>present in the same Job fail the execution of the Job.<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. |