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

sqlsmith: improvements #37456

Merged
merged 6 commits into from
May 14, 2019
Merged

sqlsmith: improvements #37456

merged 6 commits into from
May 14, 2019

Conversation

maddyblue
Copy link
Contributor

@maddyblue maddyblue commented May 10, 2019

Various SQLsmith improvements in preparation for comparison testing and correlated subqueries.

Release note: None

@maddyblue maddyblue requested review from justinj and a team May 10, 2019 19:03
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@maddyblue maddyblue changed the title sqlsmith: allow disabling mutations sqlsmith: improvements May 10, 2019
maddyblue added 4 commits May 13, 2019 16:39
This will be used when we want to set some initial state and not have
to worry about it. Useful for comparison testing across separate servers
to avoid having to make sure changes are synced.

Release note: None
@maddyblue
Copy link
Contributor Author

ping @justinj

Copy link
Contributor

@justinj justinj left a comment

Choose a reason for hiding this comment

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

:lgtm:, sorry for the delay and thanks for the ping!

Something I think might be cool with these PRs would be to have a datadriven test that generated a handful of statements (maybe 10, maybe 100), possibly parameterized by the options framework you've added here. It could be seeded so pure refactorings wouldn't change it (up to like, reorderings of random calls, which I think is fine). There would obviously still be a lot of churn in that file but having a handful of examples of what we generate now included directly in a PR would be really nice when looking at code changes.

Reviewed 2 of 2 files at r1, 2 of 2 files at r2, 1 of 1 files at r3, 1 of 1 files at r4, 1 of 1 files at r5, 1 of 1 files at r6.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mjibson)


pkg/internal/sqlsmith/relational.go, line 336 at r5 (raw file):

}

func makeSelectTable(s *scope, refs colRefs, forJoin bool) (tree.TableExpr, colRefs, bool) {

I think this function could use a comment


pkg/internal/sqlsmith/relational.go, line 384 at r5 (raw file):

	var fromRefs colRefs
	// Sometimes generate a SELECT with no FROM clause.
	for coin() {

this seems like a high percentage of the time to me but I have no actual evidence for that


pkg/internal/sqlsmith/relational.go, line 759 at r5 (raw file):

	values, valuesRefs := makeValues(s, desiredTypes, refs)

	// Returing just &values here would result in a query like `VALUES (...)` where

nit: Returing (present in the old version as well)


pkg/internal/sqlsmith/sqlsmith.go, line 125 at r1 (raw file):

}

// SmitherOption is an option for the Smither client.

this is a cute pattern!

maddyblue added 2 commits May 14, 2019 14:57
It can now use VALUES and SELECT as table sources.

Also teach it about having no FROM sources at all.
Copy link
Contributor Author

@maddyblue maddyblue left a comment

Choose a reason for hiding this comment

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

Yes, I've wanted this too. I want to do it in a way that is fairly deterministic and doesn't cause churn here because someone moved or added a function or operator in the tree package. I'll think about this more.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @justinj and @mjibson)


pkg/internal/sqlsmith/relational.go, line 336 at r5 (raw file):

Previously, justinj (Justin Jaffray) wrote…

I think this function could use a comment

Done.


pkg/internal/sqlsmith/relational.go, line 384 at r5 (raw file):

Previously, justinj (Justin Jaffray) wrote…

this seems like a high percentage of the time to me but I have no actual evidence for that

Done.

@maddyblue
Copy link
Contributor Author

bors r+

craig bot pushed a commit that referenced this pull request May 14, 2019
37456: sqlsmith: improvements r=mjibson a=mjibson

Various SQLsmith improvements in preparation for comparison testing and correlated subqueries.

Release note: None

Co-authored-by: Matt Jibson <[email protected]>
@craig
Copy link
Contributor

craig bot commented May 14, 2019

Build succeeded

@craig craig bot merged commit a33a5cc into cockroachdb:master May 14, 2019
@maddyblue maddyblue deleted the sqlsmith-mutations branch May 14, 2019 19:29
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