Skip to main content
Generates random data with a given schema. Allows populating test tables with that data. All data types that can be stored in a table are supported, including JSON, Dynamic, Variant, BFloat16, Time and Time64. The types AggregateFunction, Interval, Nothing and QBit are not supported.

Syntax

Arguments

Settings

SETTINGS is the last argument of the call and controls how Nullable, Variant, Dynamic and JSON values are generated.
SETTINGS can also be the only argument, which keeps the structure of the insertion table:

Returned value

A table object with requested schema.

Usage Example

In combination with generateRandomStructure:
With missing structure argument (in this case the structure is random):
With random seed both for random structure and random data:
generateRandom(generateRandomStructure(), [random seed], max_string_length, max_array_length) with a large enough max_array_length can generate a really huge output due to possible big nesting depth (up to 16) of complex types (Array, Tuple, Map, Nested).

Generating JSON

A generated JSON column reads like a stream of documents of one schema: the set of keys and the type of every key are derived from the random seed and stay the same for the whole column, while the values, the absent keys and the array lengths change from row to row. The depth of the objects is bounded by max_json_depth, the number of keys on one level by max_json_keys_per_object, and a key is absent from a row with probability null_ratio. The leaves take the types the JSON parser infers for real documents: Int64, UInt64, Float64, Bool, String, Date, DateTime, arrays of those, arrays of objects and mixed arrays; a few keys carry a different type in a small fraction of the rows, as they do in data collected from an application. The type declaration shapes the generated schema: typed paths are always present with their declared type, paths excluded by SKIP and SKIP REGEXP are never generated, and both max_dynamic_paths and max_dynamic_types are respected, so the paths beyond max_dynamic_paths end up in the shared data of the column.
The structure can also be left to the insertion table, which is convenient for filling a table with JSON, Dynamic or Variant columns:
Last modified on September 25, 2026