Generate test data
The built-in load generator can generate mock data, which can be used in demos and tests. It provides an easy way to simulate the data stream without connecting to an actual external data source.
Use the SQL statement below to connect RisingWave to the built-in load generator.
Syntax
WITH
options - columnparameter
[]
The following table shows the data types that can be generated for each load generator type.
Generator \ Data | Number | Timestamp | Timestamptz | Varchar | Struct | Array |
---|---|---|---|---|---|---|
Sequence | ||||||
Random |
Select the type of data to be generated.
The sequence load generator can generate numbers, incremented by 1, from the starting number to the ending number. For example, 1
, 2
, 3
, … and 1.56
, 2.56
, 3.56
, …
Specify the following fields for every column.
column_parameter | Description | Value | Required? |
---|---|---|---|
kind | Generator type. | Set to sequence . | False. Default: random |
start | Starting number must be smaller than the ending number. | Any number of the column data type. Example: 50 | False. Default: 0 |
end | Ending number must be larger than the starting number. | Any number of the column data type. Example: 100 | False. Default: 32767 |
The sequence load generator can generate numbers, incremented by 1, from the starting number to the ending number. For example, 1
, 2
, 3
, … and 1.56
, 2.56
, 3.56
, …
Specify the following fields for every column.
column_parameter | Description | Value | Required? |
---|---|---|---|
kind | Generator type. | Set to sequence . | False. Default: random |
start | Starting number must be smaller than the ending number. | Any number of the column data type. Example: 50 | False. Default: 0 |
end | Ending number must be larger than the starting number. | Any number of the column data type. Example: 100 | False. Default: 32767 |
The random number generator produces random numbers within a certain range.
Specify the following fields for every column in the source you are creating.
column_parameter | Description | Value | Required? |
---|---|---|---|
kind | Generator type. | Set to random. | False. Default: random |
min | The minimum number can be generated. Must be smaller than the maximum number. | Any number of the column data type. Example: 50 | False. Default: 0 |
max | The maximum number can be generated. Must be larger than the minimum number. | Any number of the column data type. Example: 100 | False. Default: 32767 |
seed | A seed number that initializes the random load generator. The sequence of the generated numbers is determined by the seed value. If given the same seed number, the generator will produce the same sequence of numbers. | A positive integer. Example: 3 | False. If not specified, a fixed sequence of numbers will be generated. |
The sequence load generator can generate numbers, incremented by 1, from the starting number to the ending number. For example, 1
, 2
, 3
, … and 1.56
, 2.56
, 3.56
, …
Specify the following fields for every column.
column_parameter | Description | Value | Required? |
---|---|---|---|
kind | Generator type. | Set to sequence . | False. Default: random |
start | Starting number must be smaller than the ending number. | Any number of the column data type. Example: 50 | False. Default: 0 |
end | Ending number must be larger than the starting number. | Any number of the column data type. Example: 100 | False. Default: 32767 |
The sequence load generator can generate numbers, incremented by 1, from the starting number to the ending number. For example, 1
, 2
, 3
, … and 1.56
, 2.56
, 3.56
, …
Specify the following fields for every column.
column_parameter | Description | Value | Required? |
---|---|---|---|
kind | Generator type. | Set to sequence . | False. Default: random |
start | Starting number must be smaller than the ending number. | Any number of the column data type. Example: 50 | False. Default: 0 |
end | Ending number must be larger than the starting number. | Any number of the column data type. Example: 100 | False. Default: 32767 |
The random number generator produces random numbers within a certain range.
Specify the following fields for every column in the source you are creating.
column_parameter | Description | Value | Required? |
---|---|---|---|
kind | Generator type. | Set to random. | False. Default: random |
min | The minimum number can be generated. Must be smaller than the maximum number. | Any number of the column data type. Example: 50 | False. Default: 0 |
max | The maximum number can be generated. Must be larger than the minimum number. | Any number of the column data type. Example: 100 | False. Default: 32767 |
seed | A seed number that initializes the random load generator. The sequence of the generated numbers is determined by the seed value. If given the same seed number, the generator will produce the same sequence of numbers. | A positive integer. Example: 3 | False. If not specified, a fixed sequence of numbers will be generated. |
The random timestamp and timestamptz generator produces random timestamps and timestamps with time zone, respectively, earlier than the current date and time or the source creation time.
Specify the following fields for every column in the source you are creating.
column_parameter | Description | Value | Required? |
---|---|---|---|
kind | Generator type. | Set to random . | False. Default: random |
max_past | Specify the maximum deviation from the baseline timestamp or timestamptz to determine the earliest possible timestamp or timestamptz that can be generated. | An interval. Example: 2h 37min | False. Default: 1 day |
max_past_mode | Specify the baseline timestamp or timestamptz. The range for generated timestamps or timestamptzs is [base time - max_past , base time] | absolute — The base time is set to the execution time of the generator. The base time is fixed for each generation. relative — The base time is the system time obtained each time a new record is generated. | False. Default: absolute |
basetime | If set, the generator will ignore max_past_mode and use the specified time as the base time. | A date and time string. Example: 2023-04-01T16:39:57-08:00 | False. Default: generator execution time |
seed | A seed number that initializes the random load generator. The sequence of the generated timestamps or timestamptzs is determined by the seed value. If given the same seed number, the generator will produce the same sequence of timestamps or timestamptzs. | A positive integer. Example: 3 | False. If not specified, a fixed sequence of timestamps or timestamptzs will be generated (if the system time is constant). |
The random varchar generator produces random combination of uppercase and lowercase letters and numbers.
Specify the following fields for every column in the source you are creating.
column_parameter | Description | Value | Required? |
---|---|---|---|
kind | Generator type. | Set to random . | False. Default: random |
length | The length of the varchar to be generated. | A positive integer. Example: 16 | False. Default: 10 |
seed | A seed number that initializes the random load generator. The sequence of the generated characters is determined by the seed value. If given the same seed number, the generator will produce the same sequence of characters. | A positive integer. Example: 3 | False. If not specified, a fixed sequence of characters will be generated. |
The generator supports generating data in a struct. A column of struct
type can contain multiple nested columns of different types.
The following statement creates a load generator source which contains one column, v1
. v1
consists of two nested columns v2
and v3
.
You need to configure each nested column in the struct. Select other tabs according to the data type of the nested columns for information on column parameters.
When you configure a nested column, use column.nested_column
to specify it. For example, v1.v2
and v1.v3
in the WITH
clause above.
The generator supports generating data in an array. An array is a list of elements of the same type. Append []
to the data type of the column when creating the source.
The following statement creates a load generator source which contains one column, c1
. c1
is an array of varchar
.
You need to specify the number of elements in the array in the WITH
clause. fields.c1.length = '3'
in the example above means that c1
is an array of three elements.
When you configure the elements in an array, use column._
to specify them. For example, c1._
in the WITH
clause above.
Select other tabs according to the data type of the array for information on column parameters.
If you want to generate an array of struct, your statement should look like the following.
Example
Here is an example of connecting RisingWave to the built-in load generator.
The following statement creates a source s1
with five columns:
i1
— An array of three integers starting from 1 and incrementing by 1v1
— Structs that contain random integersv2
ranging from -10 to 10 and random floating-point numbersv3
ranging from 15 to 55t1
— Random timestamps from as early as 2 hours as 37 minutes prior to the generator execution timez1
- Random timestamps with timezones from as early as 2 hours as 37 minutes prior to the generator execution timec1
— Random strings with each consists of 16 characters
Let’s query s1
after a few seconds.
Was this page helpful?