Prerequisites
Before ingesting data from NATS JetStream into RisingWave, please ensure the following:- The NATS JetStream server is running and accessible from your RisingWave cluster.
- If authentication is required for the NATS JetStream server, make sure you have the client username and password. The client user must have the
subscribepermission for the subject. - Create the NATS subject from which you want to ingest data.
- Ensure that your RisingWave cluster is running.
Ingest data into RisingWave
When creating a source, you can choose to persist the data from the source in RisingWave by usingCREATE TABLE instead of CREATE SOURCE and specifying the connection settings and data format.
Syntax
RisingWave performs primary key constraint checks on tables with connector settings but not on regular sources. If you need the checks to be performed, please create a table with connector settings.For a table with primary key constraints, if a new data record with an existing key comes in, the new record will overwrite the existing record.
- Use alphanumeric values.
- Avoid spaces, tabs, periods (
.), greater than (>) or asterisks (*). - Do not include path separators (forward slash or backward slash).
- Keep the name length limited to 32 characters as the JetStream storage directories include the account, stream name, and consumer name.
- Avoid using reserved file names like
NULorLPT1. - Be cautious of case sensitivity in file systems. To prevent collisions, ensure that stream or account names do not clash due to case differences. For example,
Fooandfoowould collide on Windows or macOS systems.
Parameters
Examples
The following SQL query creates a table that ingests data from a NATS JetStream source.Stream creation security
Starting in v2.5, RisingWave does not create NATS streams automatically by default (
allow_create_stream = false). This prevents accidental stream creation in production environments due to typos or misconfigurations.
To enable automatic stream creation, set allow_create_stream = 'true'. Only enable this in development environments or when you specifically want RisingWave to manage stream creation.