-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
generateRandomStructure
that generates random table structure. It can be used in combination with table functiongenerateRandom
.Documentation entry for user-facing changes