Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi statement, Attach, Detach, Use statements support #1

Merged
merged 7 commits into from
Jun 13, 2024

Conversation

hmeriann
Copy link
Contributor

@hmeriann hmeriann commented Jun 5, 2024

  • Added multi-statement generation to the fuzzyduck.cpp;
  • StatementGenerator::RandomValue() and StatementGenerator::RandomPercentage() became public to be used in fuzzyduck.cpp

…or::RandomValue() and StatementGenerator::RandomPercentage() became public
@Tmonster
Copy link
Collaborator

Tmonster commented Jun 5, 2024

Awesome! Are you maybe missing a couple of files? Or maybe forgot to add some changes?
The PR here has the following files changed https://github.com/hmeriann/duckdb/pull/7/files,

extension/sqlsmith/fuzzyduck.cpp
extension/sqlsmith/include/fuzzyduck.hpp
extension/sqlsmith/include/statement_generator.hpp
extension/sqlsmith/statement_generator.cpp
extension/sqlsmith/statement_simplifier.cpp

while this PR only has the following 2 files changed

src/fuzzyduck.cpp
src/include/statement_generator.hpp

@Tmonster
Copy link
Collaborator

Tmonster commented Jun 5, 2024

Edit: Nevermind, this is just for multi statements, and the PR to add attach & use will come later

@hmeriann hmeriann changed the title Multi statement Multi statement, Attach, Detach, Use statements support Jun 6, 2024
@hmeriann
Copy link
Contributor Author

hmeriann commented Jun 6, 2024

@Mytherin could you please have a look at this PR?

Copy link
Collaborator

@Tmonster Tmonster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the one comment. Otherwise Looks good to me from here

#include "duckdb/parser/statement/update_statement.hpp"
#include "duckdb/parser/tableref/list.hpp"

#define TESTING_DIRECTORY_NAME "duckdb_unittest_tempdir"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that duckdb_sqlsmith is an extension and has duckdb as a submodule is it possible to use the TESTING_DIRECTORY_NAME declaration from test/helpers/test_helpers.cpp?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might have to include duckdb/test/include/test_helpers.hpp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defined new TESTING_DIRECTORY_NAME, also put it in the .gitignore

@hmeriann hmeriann requested a review from Tmonster June 6, 2024 11:58
@Tmonster
Copy link
Collaborator

Tmonster commented Jun 7, 2024

Oh shoot, I'm just realizing now that maybe the duckdb_sqlsmith_unittest_tempdir might not actually be a good idea. If people build DUCKDB with the sqlsmith extension, then the duckdb_qlsmith_unittest_tempdir is not in the duckdb .gitignore. This means there will be a bunch of unittest files that github is automatically tracking. I'm going to test this first to make sure I'm right

Copy link
Collaborator

@Tmonster Tmonster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think we should stick with "duckdb_unittest_tempdir". This directory is already in the .gitignore. Also, if someone builds sqlsmith in the duckdb directory or in the sqlsmith directory, the databases attached by the attach and use will automatically be in the .gitignore

auto info = make_uniq<AttachInfo>();
auto fs = FileSystem::CreateLocal();
// check if the directory exists
if (!fs->DirectoryExists(string("../") + TESTING_DIRECTORY_NAME)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the "../" these cause the testing directory to end up in a weird place

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed - now it puts files generated during testing to the proper duckdb_unittest_tempdir

Copy link
Contributor

@Mytherin Mytherin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Perhaps in the future we want to, instead of using USE, directly refer to attached databases in queries? That way we can also fuzz queries that access multiple databases, e.g.:

ATTACH ':memory:' AS db1;
CREATE TABLE db1.t1(i INT);
ATTACH ':memory:' AS db2;
CREATE TABLE db2.t2(i INT);
SELECT * FROM db1.t1, db2.t2;

Copy link
Collaborator

@Tmonster Tmonster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍 . Also agree with Mark that we can just directly refer to persistent databases in the future instead of using USE

@Tmonster
Copy link
Collaborator

Have created an issue for fuzzing across databases #2.
Re-running the windows job to confirm failure is due to github-wide issue of replacing windows machines

@Tmonster Tmonster merged commit b0fce59 into duckdb:main Jun 13, 2024
10 of 12 checks passed
@Tmonster
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants