Skip to content

Add support for JSON, Dynamic, Variant, BFloat16, Time, and Time64 in GenerateRandom - #107966

Merged
naushniki merged 16 commits into
ClickHouse:masterfrom
apst41:feature/generate-random-json-dynamic-variant
Sep 23, 2026
Merged

naushniki merged 16 commits into
ClickHouse:masterfrom
apst41:feature/generate-random-json-dynamic-variant

Conversation

@apst41

@apst41 apst41 commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #92360
Related: #94832

Edited on 2026-09-22 by @naushniki. Commit 50e2817 was added on top of @apst41's work. It keeps the type support from the earlier commits, but replaces the JSON, Dynamic and Variant generators and the session setting with the arguments requested in the issue: max nesting depth, max keys per object and a null ratio, as SETTINGS of the table function and the engine. Reasons: the issue asks for exactly these knobs; a session setting cannot be persisted by CREATE TABLE ... ENGINE = GenerateRandom (also noted by the CI review); flat _rnd_N paths with random scalars do not exercise nested objects, shared data, SKIP rules or subcolumn reads, which is what a test-data generator for JSON is for. The original text is kept with strikethrough where it no longer applies; the new behaviour follows each struck part.

generateRandom() table function and the GenerateRandom storage engine threw NOT_IMPLEMENTED for the JSON, Dynamic, Variant, BFloat16, Time, and Time64 types. This PR adds full support for all of them.

What changed:

  • JSON (TypeIndex::Object): typed paths are filled recursively via the existing dispatch; a configurable number of random dynamic paths (controlled by the new generate_random_max_json_dynamic_keys setting, default 5) are generated; shared data is left empty. Each JSON column gets a schema derived from the seed: readable key names from a fixed vocabulary, nested objects up to max_json_depth, at most max_json_keys_per_object keys per level, sparse keys, SKIP and SKIP REGEXP rules, arrays of objects, mixed arrays and per-key type drift. Paths beyond max_dynamic_paths go to shared data. The same seed gives the same documents.

  • Dynamic (TypeIndex::Dynamic): ~~values are drawn from a pool of four scalar types (UInt64, Int64, Float64, String); ~6 % of rows are NULL.~~ A type schema is drawn per query from a pool that imitates what the JSON parser infers, and the column is built in bulk. The NULL share is null_ratio. max_dynamic_types is honoured, including 0.

  • Variant (TypeIndex::Variant): for each row a random variant type is chosen and one value is inserted; one out of variants.size() + 1 outcomes inserts the untyped-null (NULL_DISCRIMINATOR) state. Discriminators are drawn in bulk and each variant is filled with the existing generator of its type. The NULL share is null_ratio.

  • BFloat16 / Time / Time64: BFloat16 fills raw bits like UInt16. Time and Time64 generate values clamped to [-999:59:59, 999:59:59] (and its 10^scale equivalent for Time64) so that random raw integers no longer saturate to the display boundary. (Edit: the Time cases now also honour the fuzzy mode used for the other date and time types.)

  • estimateValueSize extended for Dynamic, Variant, and Object and now accepts and propagates max_json_dynamic_keys so that block-size estimation tracks the actual setting value. and now uses the per-column schema, so that block-size estimation for preferred_block_size_bytes matches the data actually generated.

  • New setting generate_random_max_json_dynamic_keys (UInt64, default 5): limits how many randomly-generated dynamic paths each JSON object column contains. Registered in SettingsChangesHistory.cpp under 26.10. Exposed via SETTINGS in SELECT (query/session level) only — GenerateRandom has no storage-settings framework, so a SETTINGS clause on CREATE TABLE ... ENGINE = GenerateRandom is not persisted in table metadata; reads always use whichever setting is active at query time.
    New SETTINGS clause on the table function and the engine, persisted in the table metadata for ENGINE = GenerateRandom:

    • max_json_depth: max nesting depth, default 3
    • max_json_keys_per_object: max keys per object, default 8
    • null_ratio: a probability factor (0.0 to 1.0) defining how often fields are omitted or null, default 0.0625, the previous fixed 1/16
    • strings size: the existing argument max_string_length
    • array size: the existing argument max_array_length
    SELECT * FROM generateRandom('x JSON', 3, 4, 2, SETTINGS max_json_depth = 1, max_json_keys_per_object = 3) LIMIT 3;
    CREATE TABLE t (x JSON) ENGINE = GenerateRandom(1) SETTINGS null_ratio = 0.2;
  • Drive-by bug fix: TableFunctionGenerateRandom.cpp was passing the label "max_string_length" to checkAndGetLiteralArgument when parsing the max_array_length positional argument; corrected to "max_array_length".

Tests: 04357_generate_random_json_dynamic_variant.sql covers all new type cases, ENGINE = GenerateRandom for each type, FORMAT Null serialization smoke tests, toTypeName checks, the new setting, and the label bug fix. Five tests, one per area: 05234_generate_random_null_ratio, 05235_generate_random_settings (validation, persistence through ATTACH), 05236_generate_random_time_bfloat16, 05237_generate_random_variant_dynamic, 05238_generate_random_json (schema properties, SKIP rules, typed paths, subcolumn reads, engine table). A performance test tests/performance/generate_random_json.xml covers JSON, Dynamic and Variant. The output for all previously supported types is unchanged for a given seed.

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The generateRandom table function and the GenerateRandom table engine support JSON, Dynamic, Variant, BFloat16, Time and Time64. Generated JSON documents have a realistic schema derived from the seed. The new settings null_ratio, max_json_depth and max_json_keys_per_object control the share of nulls and absent keys, the nesting depth and the number of keys per object, for example generateRandom('x JSON', 1, SETTINGS max_json_depth = 2).

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/107966]

Version info

  • Merged into: 26.10.1.498-master (included in 26.10 and later)

… generateRandom

`generateRandom()` and the `GenerateRandom` storage engine previously threw
`NOT_IMPLEMENTED` for the `JSON`, `Dynamic`, `Variant`, `BFloat16`, `Time`,
and `Time64` types.  This commit adds dispatch cases for all of them in
`fillColumnWithRandomData` and `estimateValueSize`.

JSON (`TypeIndex::Object`): typed paths are filled recursively using the
existing dispatch; a configurable number of dynamic paths (controlled by
the new `generate_random_max_json_dynamic_keys` setting, default 5) are
added as `Dynamic` sub-columns; shared data is left empty.

`Dynamic` (`TypeIndex::Dynamic`): values are drawn from a pool of four
scalar types (UInt64, Int64, Float64, String); ~6 % of rows are null,
matching the existing Nullable probability.

`Variant` (`TypeIndex::Variant`): for each row a random variant type is
chosen and a single value of that type is inserted via
`ColumnVariant::insertIntoVariantFrom`.

`BFloat16` / `Time` / `Time64`: straightforward fixed-size fills using
`fillBufferWithRandomNumbers`, analogous to the existing UInt16 / Int32 /
DateTime64 cases.

New setting `generate_random_max_json_dynamic_keys` (UInt64, default 5)
limits how many randomly-generated dynamic paths each JSON object column
contains, and is exposed via the `SETTINGS` clause in SELECT or CREATE.

Drive-by fix: `TableFunctionGenerateRandom.cpp` was passing the label
`"max_string_length"` to `checkAndGetLiteralArgument` when parsing the
`max_array_length` positional argument; corrected to `"max_array_length"`.

Closes: ClickHouse#92360

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@CLAassistant

CLAassistant commented Jun 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@apst41 apst41 changed the title Add support for JSON, Dynamic, Variant, BFloat16, Time, and Time64 in… Add support for JSON, Dynamic, Variant, BFloat16, Time, and Time64 Jun 19, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

Thanks for picking this up. I reviewed it against the design notes on #92360 and the ClickHouse review checklist. The type dispatch is sound and the API usage checks out: ColumnObject::create (6-arg), ColumnVariant::insertIntoVariantFrom (correct, since on a freshly built column global == local discriminator), and ColumnDynamic. A few items before this can merge.

Blockers (CI will fail):

  1. New setting not registered in settings history. generate_random_max_json_dynamic_keys must be added to src/Core/SettingsChangesHistory.cpp under the current dev version block ("26.6"), e.g. {"generate_random_max_json_dynamic_keys", 5, 5, "New setting"}. The 02995_new_settings_history stateless test fails without it.
  2. PR metadata. The changelog category block still lists every option and the changelog entry is empty (...). Keep one category (New Feature) and write a one-line user-facing entry, otherwise the metadata check fails.
  3. CLA unsigned (mergeStateStatus is BLOCKED). The CLA bot flagged the commit author "ajay tomar" as not a GitHub user, so the commit email is not linked to your account. Set the commit author email to your GitHub-linked address and sign the CLA.

Correctness / quality:

  1. Variant never generates NULL. rng() % variants.size() always selects a concrete variant, so the untyped-NULL state that a bare Variant column can hold is never exercised. Reserve one outcome for ColumnVariant::NULL_DISCRIMINATOR, e.g. rng() % (variants.size() + 1).
  2. Time / Time64 fill raw bits with no range clamp. The text range is [-999:59:59, 999:59:59] (+-3599999 seconds, scaled for Time64). Raw random Int32/Int64 lands mostly outside that and saturates to the bounds on text output, so most rows render as the same boundary value. Clamp in non-fuzzy mode, e.g. data[i] = static_cast<Int32>(rng() % (2 * range)) - range. Master already does this for DateTime64.
  3. Dynamic-path key collision. Generated keys are k0, k1, ...; if a user declares a typed path with the same name (JSON(k0 UInt32)), the typed and dynamic path sets collide in ColumnObject, which violates its path-is-either-typed-or-dynamic invariant. Prefix the generated keys or skip names already in getTypedPaths().
  4. Minor: estimateValueSize for Object hardcodes 5 * dynamic paths but the fill uses the generate_random_max_json_dynamic_keys value; they drift if the setting is raised. Only a block-sizing heuristic, but worth using the same bound.

Note: BFloat16/Time/Time64 correctly need no estimateValueSize case (they are fixed-size and hit the haveMaximumSizeOfValue() early return), so the omission there is fine.

The tests all use count() > 0, which never materializes the generated values. Adding one query that renders them (e.g. SELECT x FROM generateRandom('x JSON(a UInt32)', 1, 5, 3) LIMIT 2 FORMAT Null, plus a checked toTypeName) would catch serialization issues like the Time saturation in (5).

- Register `generate_random_max_json_dynamic_keys` in `SettingsChangesHistory.cpp`
  under the 26.6 block so the `02995_new_settings_history` test passes.

- Add NULL discriminator to `Variant` fill: one out of `variants.size() + 1`
  outcomes now inserts `NULL_DISCRIMINATOR`, exercising the untyped-null state.

- Clamp `Time` to `[-3 599 999, 3 599 999]` seconds and `Time64` to
  `[-3 599 999 * 10^scale, 3 599 999 * 10^scale]` ticks so that random raw
  `Int32`/`Int64` values no longer saturate to the boundary on text output.

- Prefix generated dynamic-path keys as `_rnd_0`, `_rnd_1`, … to avoid
  collision with user-declared typed paths such as `JSON(k0 UInt32)`.

- Propagate `max_json_dynamic_keys` through `estimateValueSize` (new default
  parameter) and use it for the `Object` case instead of the hardcoded `5`.
  Also read the setting from `context` at the `read()` call site so the
  block-size estimate tracks the actual setting value.

- Extend the stateless test with `FORMAT Null` serialization queries (catches
  text-serialization exceptions like the former `Time` saturation) and
  `toTypeName` checks for `BFloat16`, `Time`, `Time64(3)`, `Dynamic`, and
  `Variant(UInt64, String)`.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@alexey-milovidov alexey-milovidov changed the title Add support for JSON, Dynamic, Variant, BFloat16, Time, and Time64 Add support for JSON, Dynamic, Variant, BFloat16, Time, and Time64 in GenerateRandom Jun 19, 2026
@abashkeev abashkeev added the comp-table-functions Table functions for temporary read/write to external systems (FROM ... tableFunction()). label Sep 4, 2026
@fm4v fm4v assigned fm4v and naushniki and unassigned fm4v Sep 8, 2026
…eate signature

Master commit 1369f4c added the `max_dynamic_paths_upper_bound_` parameter
to `ColumnObject::create`, between `max_dynamic_paths_` and
`global_max_dynamic_paths_`. After merging master into this branch the
`TypeIndex::Object` case in `fillColumnWithRandomData` no longer compiled.

Pass the type's `getMaxDynamicPaths` for all three path limits, which is how
the three-argument `ColumnObject` constructor initializes them.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@naushniki

Copy link
Copy Markdown
Contributor

Hi @apst41, thanks again for the PR and for addressing the first review round!

I've merged the latest master into your branch and fixed a small compile incompatibility that appeared in the meantime (ColumnObject::create gained an argument), so the branch is up to date.

The one thing only you can fix is the CLA. Your commits are authored as [email protected], and that address isn't linked to any GitHub account, so the CLA bot can't match the commits to you and the PR stays blocked. Two ways to fix it:

Option A (simplest, no git changes):

  1. Add [email protected] to your GitHub account and verify it: https://github.com/settings/emails
  2. Sign the CLA: https://cla-assistant.io/ClickHouse/ClickHouse?pullRequest=107966
  3. Trigger a recheck: https://cla-assistant.io/check/ClickHouse/ClickHouse?pullRequest=107966

Option B (if you can't link that address): rewrite your two commits with an email that is already linked to your GitHub account, then sign the CLA and trigger the recheck as above. Before you do that, please pull the branch first: it now has two extra commits on top of yours (the merge from master and a small fix), so make sure they are preserved when you force-push.

Thanks a lot, and let me know if anything is unclear!

@clickhouse-gh clickhouse-gh Bot added comp-simple-engines Lightweight single-node table engines: Log/StripeLog (append-only logs), Buffer (async batching),... and removed comp-table-functions Table functions for temporary read/write to external systems (FROM ... tableFunction()). labels Sep 17, 2026
@fm4v fm4v added the can be tested Allows running workflows for external contributors label Sep 18, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a0d653c]

Summary: ✅


AI Review

Summary

This PR extends generateRandom and the GenerateRandom engine to emit JSON, Dynamic, Variant, BFloat16, Time, and Time64, with new generation settings and broader test coverage. The overall design is solid, but the current JSON schema builder drops SKIP / SKIP REGEXP constraints once a generated key becomes an array of objects, so skipped descendants can still be generated below Array(JSON) leaves.

Findings

⚠️ Majors

  • [src/Storages/StorageGenerateRandom.cpp:859] JSON(... SKIP ...) promises that excluded paths are never generated, but array-of-object leaves are built from object_type.getTypeOfNestedObjects(), which strips the parent paths_to_skip / path_regexps_to_skip. RandomSchemas::walk then draws the nested object schema from that bare type, so declarations such as JSON(SKIP children.limit.product_id) or JSON(SKIP REGEXP 'children\\.limit\\..*') can still produce skipped descendants inside children.limit[*].
    Suggested fix: propagate the parent skip rules into the nested-object type, or filter nested leaf paths against their full prefixed path before materializing them.
Tests
  • ⚠️ Add a focused stateless test that combines SKIP / SKIP REGEXP with an array-of-objects leaf, so skipped descendants under paths like children.limit.product_id are pinned by coverage.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: preserve SKIP / SKIP REGEXP semantics below Array(JSON) leaves and cover that case with a focused stateless test.

LLVM Coverage Report

Measured on commit a0d653c.

Metric Baseline Current Δ
Lines 88.10% 88.10% +0.00%
Functions 91.70% 91.70% +0.00%
Branches 79.40% 79.40% +0.00%

Changed lines: Changed C/C++ lines covered: 656/686 (95.63%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Sep 18, 2026
@apst41
apst41 force-pushed the feature/generate-random-json-dynamic-variant branch from 392ecf9 to f2cea2e Compare September 18, 2026 12:49
@apst41

apst41 commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

@naushniki Thanks for the Merging the latest master code
I have signed the CLA
Thanks for the help

…andom scan in test

Move the `generate_random_max_json_dynamic_keys` entry from the `26.6`
to the `26.10` block in `SettingsChangesHistory.cpp`, as required by
the `settings_changes_history` style check for the current version.

In `04357_generate_random_json_dynamic_variant.sql`, `SELECT count() > 0
FROM generateRandom(...) LIMIT N` applies `LIMIT` to the 1-row
aggregate result rather than the source scan, so `generateRandom`
kept generating rows until it hit `max_rows_to_read` (20M) and the
Fast test failed with `TOO_MANY_ROWS`. Wrap each `generateRandom(...)`
call (and the `GenerateRandom`-engine table reads) in a subquery with
`LIMIT` so the scan itself is bounded.
…ndom-json-dynamic-variant

# Conflicts:
#	src/Core/SettingsChangesHistory.cpp
@apst41
apst41 force-pushed the feature/generate-random-json-dynamic-variant branch from 827bac2 to 02213bd Compare September 18, 2026 13:43
`Nullable(Dynamic)` is rejected by the type system itself
(`DataTypeNullable` throws `ILLEGAL_TYPE_OF_ARGUMENT`, since `Dynamic`
already represents `NULL` internally), so `generateRandom('x
Nullable(Dynamic)', ...)` can never succeed. This caused the Fast
test to fail with `Nested type Dynamic cannot be inside Nullable
type`. Drop the invalid case rather than testing for an error that
belongs to the type system, not to `generateRandom`.
CREATE TABLE ... ENGINE = GenerateRandom with a JSON or Dynamic
column failed with:

  Code: 44. DB::Exception: Cannot create table with column of type
  Dynamic or JSON, because storage GenerateRandom doesn't support
  columns with dynamic structure. (ILLEGAL_COLUMN)

`checkForUnsupportedColumns` in InterpreterCreateQuery.cpp rejects
such columns unless the storage overrides
`supportsColumnsWithDynamicStructure()`. `StorageGenerateRandom`
generates JSON/Dynamic/Variant data just fine (the underlying
`fillColumnWithRandomData` already supports these types), it simply
never opted in to the check. Add the override, matching
`StorageMemory` and `StorageNull`.
…ndom-json-dynamic-variant

# Conflicts:
#	src/Core/SettingsChangesHistory.cpp
DataTypeVariant's constructor sorts nested types by their full names
and squashes identical types (src/DataTypes/DataTypeVariant.cpp), so
Variant(UInt64, String) is canonicalized to Variant(String, UInt64).
The test asserted the declared order rather than the canonical one,
causing the Fast test to fail with a reference mismatch.
Comment thread src/Storages/StorageGenerateRandom.cpp Resolved
Comment thread src/Storages/StorageGenerateRandom.cpp Resolved
fillColumnWithRandomData caps the real number of random dynamic paths
generated for an Object/JSON column at
min(max_json_dynamic_keys, object_type.getMaxDynamicPaths()), but
estimateValueSize still charged max_json_dynamic_keys unconditionally.
On a low-cap schema such as JSON(max_dynamic_paths=0) or
JSON(max_dynamic_paths=1), raising generate_random_max_json_dynamic_keys
made read() shrink max_block_size based on rows the generator can
never produce, degenerating throughput toward 1-row blocks. Apply the
same cap the generator uses.

Flagged by CI code review on ClickHouse#107966.
Comment thread src/Storages/StorageGenerateRandom.h Resolved
Comment thread src/Storages/StorageGenerateRandom.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing a0d653c98 with master e96f004b9 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

5 object files changed (+352.71 KiB total), 1 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/StorageGenerateRandom.cpp.o 477.47 KiB 732.02 KiB +254.55 KiB (+53.31%)
src/CMakeFiles/dbms.dir/Storages/GenerateRandomSettings.cpp.o new 90.57 KiB +90.57 KiB

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

9 translation units recompiled, 19 s compile time in total, 8 of them have a recent master baseline.

Job report

New `SETTINGS` clause on the `generateRandom` table function and the
`GenerateRandom` table engine:
- `max_json_depth`: max nesting depth, default 3
- `max_json_keys_per_object`: max keys per object, default 8
- `null_ratio`: a probability factor (0.0 to 1.0) defining how often
  fields are omitted or null, default 0.0625, the previous fixed 1/16
- strings size: the existing argument `max_string_length`
- array size: the existing argument `max_array_length`

Each `JSON` column now gets a schema derived from the seed: readable key
names, nested objects, sparse keys, typed paths, `SKIP` and `SKIP REGEXP`
rules, arrays of objects, mixed arrays and type drift. `Dynamic` and
`Variant` columns are built in bulk from a type schema drawn per query.
Values of the previously supported types are unchanged for a given seed.

The session setting `generate_random_max_json_dynamic_keys` and the test
04357 are removed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the manual approve Manual approve required to run CI label Sep 22, 2026
Comment thread src/Storages/StorageGenerateRandom.cpp Resolved
naushniki and others added 3 commits September 22, 2026 15:37
…bers

`cppcoreguidelines-pro-type-member-init` reported `JSONSchema::Leaf::absent_threshold` and
`GenerateRandomContext::schema_seed` in `StorageGenerateRandom.cpp` as never initialized by a
constructor, which fails the tidy build because the repository treats all warnings as errors. Both
fields were always assigned by every construction site before use, so adding `= 0` default member
initializers silences the check without changing the generated data for any seed.

CI: https://github.com/ClickHouse/ClickHouse/actions/runs/35714934163/job/106731303212
Report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=107966&sha=50e28174af3a4a2e5cdde0cb564fb697e92289fc&name_0=PR
PR: ClickHouse#107966

Co-Authored-By: Claude Fable 5.1 <[email protected]>
In the CI flaky check (ASan+UBSan, S3 storage, 8 parallel workers, random settings)
`05238_generate_random_json` took 75-259 s per run against the 180 s limit. The structural
checks over seed 45 now scan 2000 rows instead of 10000, the brace-depth scans 100 rows instead
of 1000 and the comparison of `distinctJSONPaths` across streams 10000 rows instead of 100000;
the `MergeTree` round trip, the tables with the tightest `max_dynamic_types` and
`max_dynamic_paths` and the `GenerateRandom` engine table moved to the new
`05239_generate_random_json_merge_tree`, with the round trip inserting 5000 rows instead of
100000. The server-side time of the statements on a Debug build went from 675 ms for the one
test to 151 ms and 136 ms for the two.

PR: ClickHouse#107966

Co-Authored-By: Claude Fable 5.1 <[email protected]>
…riant

The schema of a generated `Dynamic` column - one to four types drawn from the seed - no longer
depends on `max_types`. The limit only decides storage: the first `min(max_types, width)` types
get a variant of their own, the rest are encoded into `SharedVariant`, as `ColumnDynamic` does
once its limit is reached. `JSON` keys drift between two types for every `max_dynamic_types`,
the second type spilling into the shared variant of the path column. Values for the default
limit, `Variant` columns and all other types are unchanged for a given seed.

Tests 05237 and 05238 check the dedicated and shared types of `Dynamic(max_types=1)` and
`JSON(max_dynamic_types=1)` and a `MergeTree` round trip of the shared values.

Addresses: ClickHouse#107966 (comment)
PR: ClickHouse#107966

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Comment thread src/Storages/StorageGenerateRandom.cpp Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-simple-engines Lightweight single-node table engines: Log/StripeLog (append-only logs), Buffer (async batching),... manual approve Manual approve required to run CI pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: support JSON type in generateRandom()

8 participants