Add new function generateRandomStructure#47409
Conversation
|
Random2 😂 |
|
This is an automated comment for commit 58610f1 with description of existing statuses. It's updated for the latest CI running
|
| TypeIndex::Array, | ||
| TypeIndex::Tuple, | ||
| TypeIndex::Map, |
There was a problem hiding this comment.
Fun fact: AFAICT, the expected size of the output of generateRandom(generateRandomStructure(), [random seed], max_array_length) is infinite iff max_array_length >= 26 (default is 10). Because it becomes a "St Petersburg lottery" on nesting depth of arrays: as array nesting depth increases, the size would increase faster than the probability would decrease.
More specifically, we'd be in trouble if expected_array_length * probability_of_array + expected_tuple_length * probability_of_tuple > 1. (Capping depth at 32 wouldn't do much because expected_array_length^32 is still huge.)
Not sure if there's a good way to document or check that. Maybe just mention it in a comment somewhere, if this seems correct and useful.
|
@al13n321 thanks for review! I rewrote this code several times, so it's cool to have a fresh look (I see some obvious mistakes, that I didn't noticed after code rewrite, feel stupid :) |
|
It breaks CI: #50537 |
|
Guess my math about St Petersburg lottery (in comment above) was wrong 😅 |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add new function
generateRandomStructurethat generates random table structure. It can be used in combination with table functiongenerateRandom.Documentation entry for user-facing changes