DataGen SQL Connector

Scan Source: Bounded Scan Source: UnBounded

The DataGen connector allows for reading by data generation rules.

The DataGen connector can work with Computed Column syntax. This allows you to generate records flexibly.

The DataGen connector is built-in.

Attention Complex types are not supported: Array, Map, Row. Please construct these types by computed column.

How to create a DataGen table

The boundedness of table: when the generation of field data in the table is completed, the reading is finished. So the boundedness of the table depends on the boundedness of fields.

For each field, there are two ways to generate data:

  • Random generator is the default generator, you can specify random max and min values. For char/varchar/string, the length can be specified. It is a unbounded generator.
  • Sequence generator, you can specify sequence start and end values. It is a bounded generator, when the sequence number reaches the end value, the reading ends.
  1. CREATE TABLE datagen (
  2. f_sequence INT,
  3. f_random INT,
  4. f_random_str STRING,
  5. ts AS localtimestamp,
  6. WATERMARK FOR ts AS ts
  7. ) WITH (
  8. 'connector' = 'datagen',
  9. -- optional options --
  10. 'rows-per-second'='5',
  11. 'fields.f_sequence.kind'='sequence',
  12. 'fields.f_sequence.start'='1',
  13. 'fields.f_sequence.end'='1000',
  14. 'fields.f_random.min'='1',
  15. 'fields.f_random.max'='1000',
  16. 'fields.f_random_str.length'='10'
  17. )

Connector Options

OptionRequiredDefaultTypeDescription
connector
required(none)StringSpecify what connector to use, here should be ‘datagen’.
rows-per-second
optional10000LongRows per second to control the emit rate.
fields.#.kind
optionalrandomStringGenerator of this ‘#’ field. Can be ‘sequence’ or ‘random’.
fields.#.min
optional(Minimum value of type)(Type of field)Minimum value of random generator, work for number types.
fields.#.max
optional(Maximum value of type)(Type of field)Maximum value of random generator, work for number types.
fields.#.length
optional100IntegerLength for string generating of random generator, work for char/varchar/string.
fields.#.start
optional(none)(Type of field)Start value of sequence generator.
fields.#.end
optional(none)(Type of field)End value of sequence generator.