ClickHouse/tests/queries/0_stateless/02919_storage_fuzzjson.sql
Ubuntu a85cf758b0 Fuzz JSON table function
Create a table function `fuzzJSON`

An example query:
```
CREATE NAMED COLLECTION json_fuzzer AS json_str={};

SELECT *
FROM fuzzJSON(json_fuzzer, json_str = '{"students" : ["Alice", "Bob"]}', random_seed = 666, max_output_length = 128, probability = 0.9)
LIMIT 3

Query id: 7f802052-efb0-41b4-87fa-03b7dd290e9d

┌─json──────────────────────────────────────────────────────────────────────────────────┐
│ {"ade0yX":[9200406572736542991, true, "sm"]}                                          │
│ {"students":["Alice", "eSN3WO#a6NYTBe0$#OWwyIQ"], "cVoP2BuQugQ":17384271928263249403} │
│ {"students":["Alice", "Bob", "T+-k4+PJGkL%XRRaF2BoeN@&A"]}                            │
└───────────────────────────────────────────────────────────────────────────────────────┘
```

Next step:
* Generate invalid string

Fixes #35962

add Object('json')

use named collection
2023-11-28 01:58:24 +00:00

45 lines
1.2 KiB
SQL

DROP TABLE IF EXISTS 02919_test_table_noarg;
CREATE TABLE 02919_test_table_noarg(str String) ENGINE = FuzzJSON('{}');
SELECT count() FROM (SELECT * FROM 02919_test_table_noarg LIMIT 100);
DROP TABLE IF EXISTS 02919_test_table_noarg;
--
DROP TABLE IF EXISTS 02919_test_table_valid_args;
CREATE TABLE 02919_test_table_valid_args(str String) ENGINE = FuzzJSON(
'{"pet":"rat"}', NULL);
SELECT count() FROM (SELECT * FROM 02919_test_table_valid_args LIMIT 100);
DROP TABLE IF EXISTS 02919_test_table_valid_args;
--
DROP TABLE IF EXISTS 02919_test_table_reuse_args;
CREATE TABLE 02919_test_table_reuse_args(str String) ENGINE = FuzzJSON(
'{
"name": "Jane Doe",
"age": 30,
"city": "New York",
"contacts": {
"email": "jane@example.com",
"phone": "+1234567890"
},
"skills": [
"JavaScript",
"Python",
{
"frameworks": ["React", "Django"]
}
],
"projects": [
{"name": "Project A", "status": "completed"},
{"name": "Project B", "status": "in-progress"}
]
}',
12345);
SELECT count() FROM (SELECT * FROM 02919_test_table_reuse_args LIMIT 100);
DROP TABLE IF EXISTS 02919_test_table_reuse_args;