Skip to content

Conversation

@jycor
Copy link
Contributor

@jycor jycor commented Jul 25, 2025

This PR adds a way to write script plan tests and includes code to generate plans as well.
This allows us to write script tests that also enforce specific query plans.

@jycor jycor force-pushed the james/script-plans branch from d32306e to 2fa0640 Compare July 25, 2025 20:13
// ExpectedColumns indicates the Name and Type of the columns expected; no other schema fields are tested.
ExpectedColumns sql.Schema

// TODO: replace this with ExpectedPlan
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be replaced with ExpectedPlan. There's a lot of cases where you don't care about the exact plan, only that a certain index or join type gets used. Forcing the test to validate a specific plan makes the test much more brittle.

// The string representation of indexes that we expect to appear in the query plan
ExpectedIndexes []string

// TODO: replace this with ExpectedPlan
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

fmt.Fprintf(&buf, `// Copyright 2024 Dolthub, Inc.
func writeHeader(buf *bytes.Buffer, pkg string) {
_, _ = fmt.Fprint(buf, "// Code generated by plangen.\n\n")
_, _ = fmt.Fprint(buf, `// Copyright 2024-2025 Dolthub, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

This can just say 2025

@jycor jycor merged commit f8574b7 into main Jul 25, 2025
8 checks passed
@jycor jycor deleted the james/script-plans branch July 25, 2025 22:42
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