Skip to content

Commit

Permalink
fix GenerateStarexpression to return only star expression, when verif…
Browse files Browse the repository at this point in the history
…ication_enabled=true

fix GenerateStarexpression to return only star expression, when verification_enabled=true

fix GenerateStarexpression to return only star expression, when verification_enabled=true
  • Loading branch information
hmeriann committed Jul 17, 2024
1 parent 6ac497d commit ba0ba08
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "duckdb"]
path = duckdb
url = https://github.com/duckdb/duckdb.git
url = https://github.com/duckdb/duckdb
branch = main
[submodule "extension-ci-tools"]
path = extension-ci-tools
Expand Down
8 changes: 5 additions & 3 deletions src/fuzzyduck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@

namespace duckdb {

FuzzyDuck::FuzzyDuck(ClientContext &context) : context(context) {}
FuzzyDuck::FuzzyDuck(ClientContext &context) : context(context) {
}

FuzzyDuck::~FuzzyDuck() {}
FuzzyDuck::~FuzzyDuck() {
}

void FuzzyDuck::BeginFuzzing() {
auto &random_engine = RandomEngine::Get(context);
Expand Down Expand Up @@ -74,7 +76,7 @@ string FuzzyDuck::GenerateQuery() {
// multi statement
idx_t number_of_statements = generator.RandomValue(1000);
LogTask("Generating Multi-Statement query of " + to_string(number_of_statements) + " statements with seed " +
to_string(seed));
to_string(seed));
for (idx_t i = 0; i < number_of_statements; i++) {
statement += generator.GenerateStatement()->ToString() + "; ";
}
Expand Down
43 changes: 21 additions & 22 deletions src/statement_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ unique_ptr<QueryNode> StatementGenerator::GenerateQueryNode() {
select_node->groups.group_expressions = GenerateChildren(1, 5);
auto group_count = select_node->groups.group_expressions.size();
if (RandomPercentage(70)) {
// single GROUP BY
GroupingSet set;
for (idx_t i = 0; i < group_count; i++) {
set.insert(i);
}
select_node->groups.grouping_sets.push_back(std::move(set));
// single GROUP BY
GroupingSet set;
for (idx_t i = 0; i < group_count; i++) {
set.insert(i);
}
select_node->groups.grouping_sets.push_back(std::move(set));
} else {
// multiple grouping sets
while (true) {
Expand Down Expand Up @@ -377,7 +377,7 @@ unique_ptr<QueryNode> StatementGenerator::GenerateQueryNode() {
GenerateCTEs(*setop);
setop->setop_type = Choose<SetOperationType>({SetOperationType::EXCEPT, SetOperationType::INTERSECT,
SetOperationType::UNION, SetOperationType::UNION_BY_NAME});
setop->left = GenerateQueryNode();
setop->left = GenerateQueryNode();
setop->right = GenerateQueryNode();
switch (setop->setop_type) {
case SetOperationType::EXCEPT:
Expand Down Expand Up @@ -818,9 +818,8 @@ unique_ptr<ParsedExpression> StatementGenerator::GenerateFunction() {
}
}
// FIXME: add export_state
auto func_expr = make_uniq<FunctionExpression>(std::move(name), std::move(children), std::move(filter), std::move(order_bys),
return make_uniq<FunctionExpression>(std::move(name), std::move(children), std::move(filter), std::move(order_bys),
distinct);
return func_expr;
}

unique_ptr<OrderModifier> StatementGenerator::GenerateOrderByAll() {
Expand All @@ -834,7 +833,7 @@ unique_ptr<OrderModifier> StatementGenerator::GenerateOrderByAll() {

unique_ptr<OrderModifier> StatementGenerator::GenerateOrderBy() {
auto result = make_uniq<OrderModifier>();
while (true) {
while (true) {
auto order_type = Choose<OrderType>({OrderType::ASCENDING, OrderType::DESCENDING, OrderType::ORDER_DEFAULT});
auto null_type = Choose<OrderByNullType>(
{OrderByNullType::NULLS_FIRST, OrderByNullType::NULLS_LAST, OrderByNullType::ORDER_DEFAULT});
Expand Down Expand Up @@ -1230,21 +1229,21 @@ string StatementGenerator::GenerateRelationName() {
}

string StatementGenerator::GenerateColumnName() {
if (parent) {
auto parent_column = parent->GenerateColumnName();
if (current_column_names.empty()) {
return parent_column;
}
if (parent_column.empty() || RandomPercentage(80)) {
return Choose(current_column_names);
}
if (parent) {
auto parent_column = parent->GenerateColumnName();
if (current_column_names.empty()) {
return parent_column;
} else {
if (current_column_names.empty()) {
return string();
}
}
if (parent_column.empty() || RandomPercentage(80)) {
return Choose(current_column_names);
}
return parent_column;
} else {
if (current_column_names.empty()) {
return string();
}
return Choose(current_column_names);
}
}

idx_t StatementGenerator::RandomValue(idx_t max) {
Expand Down

0 comments on commit ba0ba08

Please sign in to comment.