Skip to content

Commit 368ede6

Browse files
authored
Merge pull request ClickHouse#77415 from PedroTadim/buzzhouse-update
Next BuzzHouse update
2 parents fb47c96 + e545321 commit 368ede6

File tree

13 files changed

+459
-302
lines changed

13 files changed

+459
-302
lines changed

programs/client/FuzzLoop.cpp

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -454,79 +454,7 @@ bool Client::buzzHouse()
454454
UNUSED(v);
455455

456456
outf << "--Session seed: " << rg.getSeed() << std::endl;
457-
DB::Strings defaultSettings
458-
= {"engine_file_truncate_on_insert",
459-
"allow_aggregate_partitions_independently",
460-
"allow_archive_path_syntax",
461-
"allow_asynchronous_read_from_io_pool_for_merge_tree",
462-
"allow_changing_replica_until_first_data_packet",
463-
"allow_create_index_without_type",
464-
"allow_custom_error_code_in_throwif",
465-
"allow_ddl",
466-
"allow_deprecated_database_ordinary",
467-
"allow_deprecated_error_prone_window_functions",
468-
"allow_deprecated_snowflake_conversion_functions",
469-
"allow_deprecated_syntax_for_merge_tree",
470-
"allow_distributed_ddl",
471-
"allow_drop_detached",
472-
"allow_execute_multiif_columnar",
473-
"allow_experimental_analyzer",
474-
"allow_experimental_codecs",
475-
"allow_experimental_database_materialized_mysql",
476-
"allow_experimental_database_materialized_postgresql",
477-
"allow_experimental_dynamic_type",
478-
"allow_experimental_full_text_index",
479-
"allow_experimental_funnel_functions",
480-
"allow_experimental_hash_functions",
481-
"allow_experimental_inverted_index",
482-
"allow_experimental_join_right_table_sorting",
483-
"allow_experimental_json_type",
484-
"allow_experimental_kafka_offsets_storage_in_keeper",
485-
"allow_experimental_live_view",
486-
"allow_experimental_materialized_postgresql_table",
487-
"allow_experimental_nlp_functions",
488-
"allow_experimental_parallel_reading_from_replicas",
489-
"allow_experimental_query_deduplication",
490-
"allow_experimental_shared_set_join",
491-
"allow_experimental_statistics",
492-
"allow_experimental_time_series_table",
493-
"allow_experimental_variant_type",
494-
"allow_experimental_vector_similarity_index",
495-
"allow_experimental_window_view",
496-
"allow_get_client_http_header",
497-
"allow_hyperscan",
498-
"allow_introspection_functions",
499-
"allow_materialized_view_with_bad_select",
500-
"allow_named_collection_override_by_default",
501-
"allow_non_metadata_alters",
502-
"allow_nonconst_timezone_arguments",
503-
"allow_nondeterministic_mutations",
504-
"allow_nondeterministic_optimize_skip_unused_shards",
505-
"allow_prefetched_read_pool_for_local_filesystem",
506-
"allow_prefetched_read_pool_for_remote_filesystem",
507-
"allow_push_predicate_when_subquery_contains_with",
508-
"allow_reorder_prewhere_conditions",
509-
"allow_settings_after_format_in_insert",
510-
"allow_simdjson",
511-
"allow_statistics_optimize",
512-
"allow_suspicious_codecs",
513-
"allow_suspicious_fixed_string_types",
514-
"allow_suspicious_indices",
515-
"allow_suspicious_low_cardinality_types",
516-
"allow_suspicious_primary_key",
517-
"allow_suspicious_ttl_expressions",
518-
"allow_suspicious_variant_types",
519-
"allow_suspicious_types_in_group_by",
520-
"allow_suspicious_types_in_order_by",
521-
"allow_unrestricted_reads_from_keeper",
522-
"enable_analyzer",
523-
"enable_deflate_qpl_codec",
524-
"enable_zstd_qat_codec",
525-
"type_json_skip_duplicated_paths",
526-
"allow_experimental_database_iceberg",
527-
"allow_experimental_bfloat16_type",
528-
"allow_not_comparable_types_in_order_by",
529-
"allow_not_comparable_types_in_comparison_functions"};
457+
DB::Strings defaultSettings = {"engine_file_truncate_on_insert"};
530458
defaultSettings.emplace_back(rg.nextBool() ? "s3_truncate_on_insert" : "s3_create_new_file_on_insert");
531459

532460
full_query.resize(0);
@@ -675,7 +603,7 @@ bool Client::buzzHouse()
675603

676604
sq4.Clear();
677605
full_query.resize(0);
678-
qo.generateImportQuery(gen, t, sq2, sq4);
606+
qo.generateImportQuery(rg, gen, t, sq2, sq4);
679607
BuzzHouse::SQLQueryToString(full_query, sq4);
680608
outf << full_query << std::endl;
681609
server_up &= processBuzzHouseQuery(full_query);

src/Client/BuzzHouse/AST/SQLProtoStr.cpp

Lines changed: 80 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ CONV_FN(ExprColAlias, eca)
118118
}
119119
}
120120

121-
void convertToSQLString(String & ret, const String & s)
121+
static void convertToSQLString(String & ret, const String & s)
122122
{
123123
for (size_t i = 0; i < s.length(); i++)
124124
{
@@ -704,7 +704,7 @@ CONV_FN(EnumDefValue, edf)
704704
ret += std::to_string(edf.number());
705705
}
706706

707-
void BottomTypeNameToString(String & ret, const uint32_t quote, const bool lcard, const BottomTypeName & btn)
707+
static void BottomTypeNameToString(String & ret, const uint32_t quote, const bool lcard, const BottomTypeName & btn)
708708
{
709709
using BottomTypeNameType = BottomTypeName::BottomOneOfCase;
710710
switch (btn.bottom_one_of_case())
@@ -1790,7 +1790,7 @@ CONV_FN(GenerateSeriesFunc, gsf)
17901790

17911791
CONV_FN(TableFunction, tf);
17921792

1793-
void TableOrFunctionToString(String & ret, const bool tudf, const TableOrFunction & tof)
1793+
static void TableOrFunctionToString(String & ret, const bool tudf, const TableOrFunction & tof)
17941794
{
17951795
using TableOrFunctionType = TableOrFunction::JtfOneofCase;
17961796
switch (tof.jtf_oneof_case())
@@ -2001,6 +2001,45 @@ CONV_FN(MergeTreeIndexFunc, mfunc)
20012001
ret += ")";
20022002
}
20032003

2004+
CONV_FN(GenerateRandomFunc, grfunc)
2005+
{
2006+
ret += "generateRandom('";
2007+
ret += grfunc.structure();
2008+
ret += "'";
2009+
if (grfunc.has_random_seed())
2010+
{
2011+
ret += ", ";
2012+
ret += std::to_string(grfunc.random_seed());
2013+
}
2014+
if (grfunc.has_max_string_length())
2015+
{
2016+
ret += ", ";
2017+
ret += std::to_string(grfunc.max_string_length());
2018+
}
2019+
if (grfunc.has_max_array_length())
2020+
{
2021+
ret += ", ";
2022+
ret += std::to_string(grfunc.max_array_length());
2023+
}
2024+
ret += ")";
2025+
}
2026+
2027+
static void ValuesStatementToString(String & ret, const bool tudf, const ValuesStatement & values)
2028+
{
2029+
ret += "VALUES ";
2030+
ret += tudf ? "(" : "";
2031+
ret += "(";
2032+
ExprListToString(ret, values.expr_list());
2033+
ret += ")";
2034+
for (int i = 0; i < values.extra_expr_lists_size(); i++)
2035+
{
2036+
ret += ", (";
2037+
ExprListToString(ret, values.extra_expr_lists(i));
2038+
ret += ")";
2039+
}
2040+
ret += tudf ? ")" : "";
2041+
}
2042+
20042043
CONV_FN(TableFunction, tf)
20052044
{
20062045
using TableFunctionType = TableFunction::JtfOneofCase;
@@ -2047,6 +2086,12 @@ CONV_FN(TableFunction, tf)
20472086
TableOrFunctionToString(ret, true, tf.loop());
20482087
ret += ")";
20492088
break;
2089+
case TableFunctionType::kGrandom:
2090+
GenerateRandomFuncToString(ret, tf.grandom());
2091+
break;
2092+
case TableFunctionType::kValues:
2093+
ValuesStatementToString(ret, true, tf.values());
2094+
break;
20502095
default:
20512096
ret += "numbers(10)";
20522097
}
@@ -3016,71 +3061,9 @@ CONV_FN(Drop, dt)
30163061
}
30173062
}
30183063

3019-
CONV_FN(ValuesStatement, values)
3020-
{
3021-
if (values.has_setting_values())
3022-
{
3023-
ret += "SETTINGS ";
3024-
SettingValuesToString(ret, values.setting_values());
3025-
ret += " ";
3026-
}
3027-
ret += "VALUES (";
3028-
ExprListToString(ret, values.expr_list());
3029-
ret += ")";
3030-
for (int i = 0; i < values.extra_expr_lists_size(); i++)
3031-
{
3032-
ret += ", (";
3033-
ExprListToString(ret, values.extra_expr_lists(i));
3034-
ret += ")";
3035-
}
3036-
}
3037-
3038-
CONV_FN(InsertFromFile, insert_file)
3039-
{
3040-
ret += "FROM INFILE '";
3041-
ret += insert_file.path();
3042-
ret += "'";
3043-
if (insert_file.has_fcomp())
3044-
{
3045-
ret += " COMPRESSION '";
3046-
ret += FileCompression_Name(insert_file.fcomp()).substr(4);
3047-
ret += "'";
3048-
}
3049-
if (insert_file.has_settings())
3050-
{
3051-
ret += " SETTINGS ";
3052-
SettingValuesToString(ret, insert_file.settings());
3053-
}
3054-
ret += " FORMAT ";
3055-
ret += InFormat_Name(insert_file.format()).substr(3);
3056-
}
3057-
3058-
CONV_FN(InsertSelect, insert_sel)
3059-
{
3060-
if (insert_sel.has_setting_values())
3061-
{
3062-
ret += "SETTINGS ";
3063-
SettingValuesToString(ret, insert_sel.setting_values());
3064-
ret += " ";
3065-
}
3066-
SelectToString(ret, insert_sel.select());
3067-
}
3068-
3069-
CONV_FN(InsertStringQuery, insert_query)
3070-
{
3071-
if (insert_query.has_setting_values())
3072-
{
3073-
ret += "SETTINGS ";
3074-
SettingValuesToString(ret, insert_query.setting_values());
3075-
ret += " ";
3076-
}
3077-
ret += "VALUES ";
3078-
ret += insert_query.query();
3079-
}
3080-
30813064
CONV_FN(Insert, insert)
30823065
{
3083-
if (insert.has_ctes() && insert.has_est() && insert.has_insert_select())
3066+
if (insert.has_ctes() && insert.has_est() && insert.has_select())
30843067
{
30853068
CTEsToString(ret, insert.ctes());
30863069
}
@@ -3108,21 +3091,45 @@ CONV_FN(Insert, insert)
31083091
ret += ")";
31093092
}
31103093
ret += " ";
3094+
if (!insert.has_insert_file() && insert.has_setting_values())
3095+
{
3096+
ret += "SETTINGS ";
3097+
SettingValuesToString(ret, insert.setting_values());
3098+
ret += " ";
3099+
}
31113100
if (insert.has_values())
31123101
{
3113-
ValuesStatementToString(ret, insert.values());
3102+
ValuesStatementToString(ret, false, insert.values());
31143103
}
3115-
else if (insert.has_insert_select())
3104+
else if (insert.has_select())
31163105
{
3117-
InsertSelectToString(ret, insert.insert_select());
3106+
SelectToString(ret, insert.select());
31183107
}
31193108
else if (insert.has_insert_file())
31203109
{
3121-
InsertFromFileToString(ret, insert.insert_file());
3110+
const InsertFromFile & insert_file = insert.insert_file();
3111+
3112+
ret += "FROM INFILE '";
3113+
ret += insert_file.path();
3114+
ret += "'";
3115+
if (insert_file.has_fcomp())
3116+
{
3117+
ret += " COMPRESSION '";
3118+
ret += FileCompression_Name(insert_file.fcomp()).substr(4);
3119+
ret += "'";
3120+
}
3121+
if (insert.has_setting_values())
3122+
{
3123+
ret += " SETTINGS ";
3124+
SettingValuesToString(ret, insert.setting_values());
3125+
}
3126+
ret += " FORMAT ";
3127+
ret += InFormat_Name(insert_file.format()).substr(3);
31223128
}
31233129
else if (insert.has_query())
31243130
{
3125-
InsertStringQueryToString(ret, insert.query());
3131+
ret += "VALUES ";
3132+
ret += insert.query();
31263133
}
31273134
else
31283135
{
@@ -3276,7 +3283,7 @@ CONV_FN(DeduplicateExpr, de)
32763283
if (de.has_col_list())
32773284
{
32783285
ret += " BY ";
3279-
ExprColumnListToString(ret, de.col_list());
3286+
ColumnPathListToString(ret, 0, de.col_list());
32803287
}
32813288
else if (de.has_ded_star())
32823289
{
@@ -3285,7 +3292,7 @@ CONV_FN(DeduplicateExpr, de)
32853292
else if (de.has_ded_star_except())
32863293
{
32873294
ret += " BY * EXCEPT (";
3288-
ExprColumnListToString(ret, de.ded_star_except());
3295+
ColumnPathListToString(ret, 0, de.ded_star_except());
32893296
ret += ")";
32903297
}
32913298
}

0 commit comments

Comments
 (0)