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: Various usability and bug fixes. #120504

Merged
merged 1 commit into from
May 3, 2024
Merged

Conversation

miretskiy
Copy link
Contributor

@miretskiy miretskiy commented Mar 14, 2024

This PR adds various command line flags and
sqlsmith options to improve usability and correctness:

  • Add --schema command line argument to sqlsmith so that the running database instance is not required in order to populate existing table information.
  • Add --prefix command line argument which will add prefix to every statement/expression generated by sqlsmith (this can be used for example to generalte sqllogic format)
  • Add a new smither option SimpleScalarTypes which eschews "complex types" -- such as GEOMETRY, GEOGRAPHY, and other less common types.
  • Fix a bug where DisableIndexHints option was not respected (all tables had index flags).
  • Fix a bug where pretty printing (query or expression) did not respect PostgresMode, thus producing queries that are not compatible w/ postgres (e.g. they always included type annotations).

Epic: None
Release note: None

@miretskiy miretskiy requested review from a team as code owners March 14, 2024 17:09
@miretskiy miretskiy requested review from rytaft and removed request for a team March 14, 2024 17:09
Copy link

blathers-crl bot commented Mar 14, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

cockroach-teamcity commented Mar 14, 2024

CLA assistant check
All committers have signed the CLA.

@blathers-crl blathers-crl bot added the O-community Originated from the community label Mar 14, 2024
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link

blathers-crl bot commented Mar 14, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

Thank you for updating your pull request.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

Copy link
Collaborator

@michae2 michae2 left a comment

Choose a reason for hiding this comment

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

:lgtm: Thanks Yevgeniy :)

Just two small comments.

Reviewed 5 of 8 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @miretskiy and @rytaft)


pkg/internal/sqlsmith/sqlsmith.go line 460 at r2 (raw file):

// EnableLimits causes the Smither to probabilistically emit LIMIT clauses.
var EnableLimits = simpleOption("enable LIMIT", func(s *Smither) {
	s.disableLimits = true

Should this be false?


pkg/internal/sqlsmith/type.go line 62 at r2 (raw file):

		switch t {
		case types.Box2D, types.Geography, types.Geometry, types.INet, types.PGLSN,
			types.RefCursor, types.TSQuery, types.TSVector:

suggestion: I think it would be better to construct this as an approval list rather than subtracting a disapproval list from all scalar types, because we're likely to keep adding types in the future and those types will most likely skew toward "fancy".

@miretskiy
Copy link
Contributor Author

Should this be false?

Yup.

suggestion: I think it would be better to construct this as an approval list rather than subtracting a disapproval list from all scalar types, because we're likely to keep adding types in the future and those types will most likely skew toward "fancy".
Done.

@miretskiy
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Apr 28, 2024

🔒 Permission denied

Existing reviewers: click here to make miretskiy a reviewer

@miretskiy
Copy link
Contributor Author

@michae2 -- looks like I can't merge it; will you do the honors?

Copy link
Collaborator

@michae2 michae2 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 will rebase it and then merge.

Reviewed 6 of 6 files at r3, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @rytaft)

This PR adds various command line flags and
sqlsmith options to improve usability and correctness:
 * Add `--schema` command line argument to sqlsmith
   so that the running database instance is not required
   in order to populate existing table information.
 * Add `--prefix` command line argument which will add
   prefix to every statement/expression generated by sqlsmith
   (this can be used for example to generalte sqllogic format)
 * Add a new smither option `SimpleScalarTypes` which eschews
   "complex types" -- such as GEOMETRY, GEOGRAPHY, and other less
   common types.
 * Fix a bug where `DisableIndexHints` option was not
   respected (all tables had index flags).
 * Fix a bug where pretty printing (query or expression) did
   not respect `PostgresMode`, thus producing queries that are
   not compatible w/ postgres (e.g. they always included type
   annotations).

Epic: None
Release note: None
Copy link

blathers-crl bot commented May 2, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@michae2
Copy link
Collaborator

michae2 commented May 2, 2024

bors r=michae2 a=miretskiy

@craig craig bot merged commit d15210e into cockroachdb:master May 3, 2024
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-community Originated from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants