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

Add random data to sqlsmith.randTablesN() #75159

Closed
msbutler opened this issue Jan 19, 2022 · 4 comments
Closed

Add random data to sqlsmith.randTablesN() #75159

msbutler opened this issue Jan 19, 2022 · 4 comments
Assignees
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team

Comments

@msbutler
Copy link
Collaborator

msbutler commented Jan 19, 2022

There's an outstanding to do in the function to add random data to the tables it creates.

@msbutler msbutler added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team labels Jan 19, 2022
@msbutler msbutler self-assigned this Jan 19, 2022
@msbutler
Copy link
Collaborator Author

msbutler commented Jan 20, 2022

@mgartner looking at your test in TestRandTableInserts in sql_smith_test.go, I realized it's really hard to produce valid (even simple) INSERT statements into tables created by randTablesN. Seems a lot easier to follow the approach in your test: the caller of randTablesN should first execute the returned CREATE TABLE statements and then try executing insert statements. Do you agree? If so I'll close this issue.

@cucaroach
Copy link
Contributor

@mgartner FYI

@mgartner
Copy link
Collaborator

@msbutler The TODO in randTablesN you mentioned is pretty old, and the context may be lost. I have a vague memory of coming across that comment a while ago and agreeing that there would be some benefit to creating insert statements there, but I can't remember what that alleged benefit was.

FWIW, SQLSmith has been detecting many bugs that are only reproduced when the tables have data, so it seems like this may be unnecessary.

Maybe it's time to delete that TODO? I'd support it.

@msbutler
Copy link
Collaborator Author

msbutler commented Jan 27, 2022

Sounds good! I'll delete the TODO. In the same spirit of GenerateRandInterestingTable, I'd like to create a public function in randgen called GenerateRandTable(db *gosql.DB, dbName, tableName string, numRows int) which calls randTables and tries to populate the table with n rows, like your test TestRandTableInserts. I think this function would make SQLSmith/RandGen a bit more user friendly for non sql teams, like Bulk. Let me know if you have any reservations about this idea. I'll go ahead and close this issue.

msbutler added a commit to msbutler/cockroach that referenced this issue Feb 3, 2022
PopulateRandTable populates the caller's table with random data. This helper
function aims to make it easier for engineers to develop randomized tests that
leverage randgen / sqlsmith.

I considered adding random insert statements into sqlsmith's randtables setup,
however the high probably of a faulty insert statement would cause the whole
setup to fail. See cockroachdb#75159

Informs cockroachdb#72345

Release note: None
msbutler added a commit to msbutler/cockroach that referenced this issue Feb 9, 2022
PopulateRandTable populates the caller's table with random data. This helper
function aims to make it easier for engineers to develop randomized tests that
leverage randgen / sqlsmith.

I considered adding random insert statements into sqlsmith's randtables setup,
however the high probably of a faulty insert statement would cause the whole
setup to fail. See cockroachdb#75159

In the future, I'd like to develop a new helper function
PopulateDatabaseWithRandData which calls PopulateTableWithRandData on each
table in the order of the fk dependency graph.

Informs cockroachdb#72345

Release note: None
RajivTS pushed a commit to RajivTS/cockroach that referenced this issue Mar 6, 2022
PopulateRandTable populates the caller's table with random data. This helper
function aims to make it easier for engineers to develop randomized tests that
leverage randgen / sqlsmith.

I considered adding random insert statements into sqlsmith's randtables setup,
however the high probably of a faulty insert statement would cause the whole
setup to fail. See cockroachdb#75159

In the future, I'd like to develop a new helper function
PopulateDatabaseWithRandData which calls PopulateTableWithRandData on each
table in the order of the fk dependency graph.

Informs cockroachdb#72345

Release note: None
@mgartner mgartner moved this to Done in SQL Queries Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team
Projects
Archived in project
Development

No branches or pull requests

3 participants