@@ -165,7 +165,7 @@ unique_ptr<SetStatement> StatementGenerator::GenerateSet() {
165
165
name_expr = make_uniq<ConstantExpression>(Value (name));
166
166
}
167
167
auto set = make_uniq<SetVariableStatement>(" schema" , std::move (name_expr), SetScope::AUTOMATIC);
168
- return set;
168
+ return unique_ptr_cast<duckdb::SetVariableStatement, duckdb::SetStatement>( std::move ( set)) ;
169
169
}
170
170
171
171
unique_ptr<MultiStatement> StatementGenerator::GenerateAttachUse () {
@@ -517,9 +517,19 @@ unique_ptr<TableRef> StatementGenerator::GenerateSubqueryRef() {
517
517
}
518
518
519
519
unique_ptr<TableRef> StatementGenerator::GenerateTableFunctionRef () {
520
- auto function = make_uniq<TableFunctionRef>();
521
- auto &table_function_ref = Choose (generator_context->table_functions );
522
- auto &entry = table_function_ref.get ().Cast <TableFunctionCatalogEntry>();
520
+ auto num_table_functions = generator_context->table_functions .size ();
521
+ auto random_val = RandomValue (num_table_functions);
522
+ auto original_val = random_val;
523
+ auto table_function_ref = &generator_context->table_functions [random_val];
524
+ while (table_function_ref->get ().type == CatalogType::TABLE_MACRO_ENTRY) {
525
+ random_val += 1 ;
526
+ random_val %= num_table_functions;
527
+ if (random_val == original_val) {
528
+ throw InternalException (" No table_functions to test." );
529
+ }
530
+ table_function_ref = &generator_context->table_functions [random_val];
531
+ }
532
+ auto &entry = table_function_ref->get ().Cast <TableFunctionCatalogEntry>();
523
533
auto table_function = entry.functions .GetFunctionByOffset (RandomValue (entry.functions .Size ()));
524
534
525
535
auto result = make_uniq<TableFunctionRef>();
@@ -1201,7 +1211,7 @@ string StatementGenerator::RandomString(idx_t length) {
1201
1211
1202
1212
const string charset = " $_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" ;
1203
1213
string result = " " ;
1204
- for (int i = 0 ; i < length; ++i) {
1214
+ for (idx_t i = 0 ; i < length; ++i) {
1205
1215
int randomIndex = RandomValue (charset.length ());
1206
1216
result += charset[randomIndex];
1207
1217
}
0 commit comments