Skip to content

props/physical: add printing of PlanGrams#168346

Merged
trunk-io[bot] merged 2 commits intocockroachdb:masterfrom
michae2:plangram-print
Apr 17, 2026
Merged

props/physical: add printing of PlanGrams#168346
trunk-io[bot] merged 2 commits intocockroachdb:masterfrom
michae2:plangram-print

Conversation

@michae2
Copy link
Copy Markdown
Collaborator

@michae2 michae2 commented Apr 14, 2026

opt: add Operator.CamelCase function

To make plangrams look more like opt and canned opt plans, we want to
use camel case operator names. Add a new function.

Epic: None
Release note: None


props/physical: add printing of PlanGrams

Add functions to print plangrams, and also clean up some of the structs
and comments.

Informs: #152053
Release note: None

@michae2 michae2 requested review from a team, DrewKimball, ZhouXing19 and andyyang890 April 14, 2026 17:50
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io bot commented Apr 14, 2026

😎 Merged successfully - details.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Apr 14, 2026

Detected infrastructure failure (matched: ). Automatically rerunning failed jobs. (run link)

1 similar comment
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Apr 14, 2026

Detected infrastructure failure (matched: ). Automatically rerunning failed jobs. (run link)

Copy link
Copy Markdown
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice!

@DrewKimball reviewed 6 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on andyyang890 and ZhouXing19).

Copy link
Copy Markdown
Collaborator

@andyyang890 andyyang890 left a comment

Choose a reason for hiding this comment

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

@andyyang890 made 3 comments.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on michae2 and ZhouXing19).


pkg/sql/opt/optgen/cmd/optgen/ops_gen.go line 78 at r1 (raw file):

	for _, define := range g.sorted {
		fmt.Fprintf(&indexes, "%d, ", names.Len())
		fmt.Fprint(&names, define.Name)

Is it maybe worth adding a linter or some kind of validation that the source names are all camel case already? IIUC there's an implicit assumption of that here. If there's already some validation, would you mind adding a comment explaining where the validation happens?


pkg/sql/opt/props/physical/plangram.go line 144 at r2 (raw file):

		defer b.WriteRune('\n')
	}
	if p.root == nil {

nit: use p.Any() instead


pkg/sql/opt/props/physical/plangram.go line 164 at r2 (raw file):

			return
		}
		switch t := term.(type) {

Should we have a default case for unexpected types?

michae2 added 2 commits April 17, 2026 11:33
To make plangrams look more like opt and canned opt plans, we want to
use camel case operator names. Add a new function.

Epic: None
Release note: None
Add functions to print plangrams, and also clean up some of the structs
and comments.

Informs: cockroachdb#152053
Release note: None
Copy link
Copy Markdown
Collaborator Author

@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.

TFTRs!

@michae2 made 4 comments and resolved 3 discussions.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on DrewKimball and ZhouXing19).


pkg/sql/opt/optgen/cmd/optgen/ops_gen.go line 78 at r1 (raw file):

Previously, andyyang890 (Andy Yang) wrote…

Is it maybe worth adding a linter or some kind of validation that the source names are all camel case already? IIUC there's an implicit assumption of that here. If there's already some validation, would you mind adding a comment explaining where the validation happens?

Good point, added a test.


pkg/sql/opt/props/physical/plangram.go line 144 at r2 (raw file):

Previously, andyyang890 (Andy Yang) wrote…

nit: use p.Any() instead

Done.


pkg/sql/opt/props/physical/plangram.go line 164 at r2 (raw file):

Previously, andyyang890 (Andy Yang) wrote…

Should we have a default case for unexpected types?

Done.

@michae2
Copy link
Copy Markdown
Collaborator Author

michae2 commented Apr 17, 2026

Thanks for the reviews!

/trunk merge

@trunk-io trunk-io bot merged commit c768c65 into cockroachdb:master Apr 17, 2026
26 checks passed
@michae2 michae2 deleted the plangram-print branch April 17, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants