This guide describes how to sink data from RisingWave to MongoDB. MongoDB is a document database designed for ease of application development and scaling. For more information, see MongoDB.
Parameter Name | Description |
---|---|
mongodb.url | The URL of MongoDB. |
type | Defines the type of the sink. Options include append-only or upsert . |
collection.name | The collection name where data should be written to or read from. For sinks, the format is db_name.collection_name . Data can also be written to dynamic collections, see collection.name.field below for more information. |
collection.name.field | Optional. The dynamic collection name where data should be sunk to.
|
collection.name.field.drop | Optional. Controls whether the field value of collection.name.field should be dropped when sinking. Set this option to true to avoid the duplicate values of collection.name.field being written to the result collection. |
MongoDB Type | RisingWave Type |
---|---|
Boolean | BOOLEAN |
32-bit integer | SMALLINT |
32-bit integer | INTEGER |
64-bit integer | BIGINT |
Double | REAL |
Double | DOUBLE |
Decimal128 | DECIMAL |
String | DATE |
String | VARCHAR |
String | TIME |
Date | TIMESTAMP WITHOUT TIME ZONE |
Date | TIMESTAMP WITH TIME ZONE |
String | INTERVAL |
Object | STRUCT |
Array | ARRAY |
Binary data | BYTEA |
Object | JSONB |
64-bit integer | SERIAL |
_id
field for each record, typically with a value of the ObjectId type. This is necessary because _id
is the primary key in MongoDB.
t2
is:
name | type | pk |
---|---|---|
id | int | ✔ |
value | text |
id | value |
---|---|
1 | ’example of record’ |
id
field will exist if the primary key of t2
is _id
.tenant_id
is included as a prefix in the collection name, such as sharding_2024_01.tenant1_order
. This approach offers more flexibility and enables efficient data organization and retrieval based on specific tenant requirements.
To use a dynamic collection name:
collection.name
: Serve as a fallback collection name if the value of collection.name.field
is empty or null. In this case, it defaults to demo.t2
.collection.name.field
: Specify the field used for the collection name. This field must be of type varchar
.collection.name.field.drop
: When set to true
, it avoids duplicate values of collection.name.field
in the result collection.