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

opt: add OptionalColList type #58110

Merged
merged 2 commits into from
Dec 22, 2020
Merged

Conversation

RaduBerinde
Copy link
Member

I am open to better suggestions for the name.

opt: change ColSetToList() func to a ToList() method

Release note: None

opt: add OptionalColList type

For mutations, we use ColLists that map 1-to-1 to table columns, and
where some of the entries in the list can be 0. This is really meant
to represent a mapping of columns and it is an abuse of the ColList
type (which is supposed to be a simple list of columns).

We add a separate OptionalColList type which has the desired
semantics. This helps clarify things a bit (in particular it is now
obvious which of the lists are "real" lists and which are "mappings").
It will also allow a different ToSet() method which makes sense for
this structure (i.e. doesn't put 0 in the set).

Release note: None

@RaduBerinde RaduBerinde requested a review from a team as a code owner December 20, 2020 21:18
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm:

Will you be adding ToSet in a future PR? Is there a use case for it right now?

Reviewed 6 of 6 files at r1, 9 of 9 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andy-kimball, @mgartner, and @RaduBerinde)


pkg/sql/opt/column_meta.go, line 101 at r2 (raw file):

func (cl OptionalColList) Find(col ColumnID) (idx int, ok bool) {
	for i := range cl {
		if col != 0 && cl[i] == col {

[nit] you could move a col == 0 check to the top of the function since you'll always return false in that case.

For mutations, we use ColLists that map 1-to-1 to table columns, and
where some of the entries in the list can be 0. This is really meant
to represent a mapping of columns and it is an abuse of the ColList
type (which is supposed to be a simple list of columns).

We add a separate OptionalColList type which has the desired
semantics. This helps clarify things a bit (in particular it is now
obvious which of the lists are "real" lists and which are "mappings").
It will also allow a different ToSet() method which makes sense for
this structure (i.e. doesn't put 0 in the set).

Release note: None
Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

TFTR! I have an upcoming usecase for ToSet, I will add it then.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andy-kimball, @mgartner, and @rytaft)


pkg/sql/opt/column_meta.go, line 101 at r2 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

[nit] you could move a col == 0 check to the top of the function since you'll always return false in that case.

Done.

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 1 files at r3.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andy-kimball and @mgartner)

@RaduBerinde
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Dec 21, 2020

Build failed:

Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Nice!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andy-kimball and @mgartner)

@RaduBerinde
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Dec 22, 2020
58110: opt: add OptionalColList type r=RaduBerinde a=RaduBerinde

I am open to better suggestions for the name.

#### opt: change ColSetToList() func to a ToList() method

Release note: None

#### opt: add OptionalColList type

For mutations, we use ColLists that map 1-to-1 to table columns, and
where some of the entries in the list can be 0. This is really meant
to represent a mapping of columns and it is an abuse of the ColList
type (which is supposed to be a simple list of columns).

We add a separate OptionalColList type which has the desired
semantics. This helps clarify things a bit (in particular it is now
obvious which of the lists are "real" lists and which are "mappings").
It will also allow a different ToSet() method which makes sense for
this structure (i.e. doesn't put 0 in the set).

Release note: None

58156: logictest: fix upsert test r=RaduBerinde a=yuzefovich

The trace message appears to contain only a single line if an error
occurs (all lines apart from the first one are not shown), so this
commit adjusts `upsert` opt logic test accordingly.

Fixes: #58158.

Release note: None

Co-authored-by: Radu Berinde <[email protected]>
Co-authored-by: Yahor Yuzefovich <[email protected]>
@craig
Copy link
Contributor

craig bot commented Dec 22, 2020

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Dec 22, 2020

Build succeeded:

@craig craig bot merged commit e7a3427 into cockroachdb:master Dec 22, 2020
@RaduBerinde RaduBerinde deleted the col-list-stuff branch December 22, 2020 21:05
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.

4 participants