# tMongoDBInput properties for Apache Spark Streaming (deprecated)

Availability-note[Deprecated](https://help.talend.com/r/en-US/Cloud/labels-on-talend-help-center/availability-deprecated)

This content is deprecated.

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

Information noteDeprecation: Spark Streaming is deprecated beginning with the R2026-09 release. Use Spark Structured Streaming instead.

The Spark Streaming tMongoDBInput component belongs to the Databases family.

In this type of Job, tMongDBInput is used to provide lookup data, when the size of the lookup data fits the amount of memory allocated for the execution of the Job. It is executed once to read data from MongoDB and store the data in memory so that the micro-batches from the main flow can easily access the data. If the lookup data is too large to be stored in memory, it is recommended to use tMongoDBLookupInput instead, which loads only the data matching the lookup join key.

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

## 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. |
| MongoDB configuration | Select this check box and in the Component<br>List drop-down list, select the desired connection component to<br>reuse the connection details you already defined. |
| Schema and Edit<br>Schema | A schema is a row description. It defines the number of fields<br>(columns) to be processed and passed on to the next component. When you create a Spark<br>Job, avoid the reserved word line when naming the<br>fields.<br><br>Click Edit<br>schema to make changes to the schema. If the current schema is of the Repository type, three options are available:<br><br><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><br><br>If a column in the database is a JSON document and you need to read<br>the entire document, put an asterisk (\*) in the DB<br>column column, without quotation marks around. |
| Collection | Enter the name of the collection to be used.<br><br>A MongoDB collection is the equivalent of an RDBMS table and contains<br>documents.<br><br>If the collection to be used is not shared, it is recommended to add the<br>*mongo.input.split\_size* property to the Advanced Hadoop MongoDB properties table. This<br>parameter determines how the collection is going to be partitioned and read by the<br>Spark executors. The number of partitions of the input collection can be calculated<br>using the following formula:<br><br>```<br>Number of partitions = Collection size in MB / mongo.input.split_size<br>```<br><br><br>Without<br>this property, Spark uses the default value, 8 MB, for the partition size.<br><br>For<br>example:<br><br>```<br>mongo.input.split_size   1<br>```<br><br><br>In this<br>example, Spark dispatches 1 MB to each Spark executor in order to read the<br>non-shared collection in parallel. If the collection size is 10 MB, 10 executors are<br>employed. |
| Set read preference | Select this check box and from the Read preference<br>drop-down list that is displayed, select the member to which you need to direct the read<br>operations.<br><br>If you leave this check box clear, the Job uses the default Read preference, that is to<br>say, uses the primary member in a replica set.<br><br>For further information, see MongoDB's documentation about Replication and its Read<br>preferences. |
| Query | Specify the query statement to select documents from the collection specified in the<br>Collection field. For example, type in "{'id':'4'}" to retrieve the record whose<br>*id* is<br>*4* from the<br>collection.<br><br>The default query, {} within double quotation marks provided with this<br>component, means to select all of the files. You can also apply a regular expression by<br>putting {'filename':{'$regex':'REGEX\_PATTERN'}} to define the file names to be<br>used.<br><br>Different from the query statements required in the MongoDB client software, the query<br>here refers to the contents inside find(), such as the query<br>{'filename':{'$regex':'REGEX\_PATTERN'}} here is the equivalent of<br>db.blog.find({filename:{$regex:REGEX\_PATTERN}}) in the MongoDB client<br>query. |
| Mapping | Each column of the schema defined for this component represents a field of the documents<br>to be read. In this table, you need to specify the parent nodes of these fields, if<br>any.<br><br>For example, in the document reading as<br>follows<br><br>```<br>{<br>_id: ObjectId("5099803df3f4948bd2f98391"),<br>person: { first: "Joe", last: "Walker" }<br>}<br>```<br><br><br>The<br>*first* and the *last*<br>fields have *person* as their parent node but the *\_id* field does not have any parent node. So once completed, this<br>Mapping table should read as<br>follows:<br><br>```<br>Column     Parent node path<br>_id<br>first       "person"<br>last        "person"<br>``` |
| Limit | Enter the maximum number of records to be retrieved. |

## Advanced settings

| Properties | Description |
| --- | --- |
| Advanced Hadoop MongoDB<br>properties | Add properties to define extra operations you need tMongoDBInput to perform when reading data.<br><br>The available properties are listed and explained in [MongoDB Connector for<br>Hadoop](https://github.com/mongodb/mongo-hadoop/wiki/Configuration-Reference).<br><br>If the collection to be used is not shared, it is recommended to add the<br>*mongo.input.split\_size* property to the Advanced Hadoop MongoDB properties table. This<br>parameter determines how the collection is going to be partitioned and read by the<br>Spark executors. The number of partitions of the input collection can be calculated<br>using the following formula:<br><br>```<br>Number of partitions = Collection size in MB / mongo.input.split_size<br>```<br><br><br>Without<br>this property, Spark uses the default value, 8 MB, for the partition size.<br><br>For<br>example:<br><br>```<br>mongo.input.split_size   1<br>```<br><br><br>In this<br>example, Spark dispatches 1 MB to each Spark executor in order to read the<br>non-shared collection in parallel. If the collection size is 10 MB, 10 executors are<br>employed. |

## Usage

| Usage guidance | Description |
| --- | --- |
| **Usage rule** | This component is used to provide lookup data, when the size of the lookup data fits the<br>amount of memory allocated for the execution of the Job. It is executed once to read data<br>from MongDB and store the data in memory so that the micro-batches from the main flow can<br>easily access the data. If the lookup data is too large to be stored in memory, it is<br>recommended to use tMongoDBLookupInput instead, which loads only the data<br>matching the lookup join key.<br><br>This component is used as a start component and requires an output link.<br><br>This component should use a tMongoDBConfiguration component present in the same Job to connect<br>to a MongoDB database. You need to drop a tMongoDBConfiguration component alongside this component and<br>configure the Basic settings of this component<br>to use tMongoDBConfiguration.<br><br>This component, along with the Spark Streaming component Palette it belongs to, appears<br>only when you are creating a Spark Streaming Job.<br><br>Note that in this documentation, unless otherwise explicitly stated, a scenario presents<br>only Standard Jobs, that is to say traditional<br>Talend<br>data<br>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. |