Skip to content

Commit 65ba4ec

Browse files
authored
Merge branch 'main' into migrate-py-to-sqlsmith
2 parents ece45ac + 4a6da30 commit 65ba4ec

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

.github/workflows/MainDistributionPipeline.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
name: Build extension binaries
1717
uses: duckdb/extension-ci-tools/.github/workflows/[email protected]
1818
with:
19-
duckdb_version: migrate-py-to-sqlsmith
19+
duckdb_version: main
2020
extension_name: sqlsmith
2121

2222
duckdb-stable-deploy:
@@ -25,6 +25,6 @@ jobs:
2525
uses: ./.github/workflows/_extension_deploy.yml
2626
secrets: inherit
2727
with:
28-
duckdb_version: migrate-py-to-sqlsmith
28+
duckdb_version: main
2929
extension_name: sqlsmith
3030
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}

src/statement_generator.cpp

+15-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ unique_ptr<SetStatement> StatementGenerator::GenerateSet() {
165165
name_expr = make_uniq<ConstantExpression>(Value(name));
166166
}
167167
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));
169169
}
170170

171171
unique_ptr<MultiStatement> StatementGenerator::GenerateAttachUse() {
@@ -517,9 +517,19 @@ unique_ptr<TableRef> StatementGenerator::GenerateSubqueryRef() {
517517
}
518518

519519
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>();
523533
auto table_function = entry.functions.GetFunctionByOffset(RandomValue(entry.functions.Size()));
524534

525535
auto result = make_uniq<TableFunctionRef>();
@@ -1201,7 +1211,7 @@ string StatementGenerator::RandomString(idx_t length) {
12011211

12021212
const string charset = "$_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
12031213
string result = "";
1204-
for (int i = 0; i < length; ++i) {
1214+
for (idx_t i = 0; i < length; ++i) {
12051215
int randomIndex = RandomValue(charset.length());
12061216
result += charset[randomIndex];
12071217
}

0 commit comments

Comments
 (0)