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

tree: skip nulls when type checking a list of tuples #40298

Merged
merged 1 commit into from Oct 16, 2019

Conversation

yuzefovich
Copy link
Member

@yuzefovich yuzefovich commented Aug 28, 2019

Previously, the type checking code for a list of tuples expected that
all expressions in the list are actually tuples. Now we will also allow
for nulls to be present in the list.

Fixes: #40297.

Release note (sql change): NULLs are now allowed to be among tuples when
being compared against a tuple.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@yuzefovich
Copy link
Member Author

I doubt that my WIP is the correct way to resolve the issue, but I don't know what is the expected behavior here, so any pointers/suggestions are very welcome.

As a side note, Postgres doesn't allow empty tuples, why do we allow such case?

@yuzefovich
Copy link
Member Author

Friendly ping.

@yuzefovich yuzefovich changed the title WIP skip nulls when type checking a list of tuples skip nulls when type checking a list of tuples Sep 12, 2019
@yuzefovich
Copy link
Member Author

Friendly ping. I had a WIP in the title of the PR because I don't think that it is ready to be merged, but it is definitely ready for a look. I'd appreciate any input although it doesn't seem urgent.

@jordanlewis
Copy link
Member

Are there new tests to add for this? It looks fine.

@yuzefovich yuzefovich changed the title skip nulls when type checking a list of tuples tree: skip nulls when type checking a list of tuples Sep 13, 2019
@yuzefovich
Copy link
Member Author

I expected that this approach would not be approved so didn't bother to add tests at first.

I added a test which actually uncovered a bug in my initial implementation. PTAL.

@jordanlewis
Copy link
Member

Does this PR also fix the following:

 select case when true then (1,2) else null end;

And can you add a test? There's a couple other callers of TypeCheckSameTypedExprs like this - you don't need to test them all but adding another case would be a nice to have.

Besides this LGTM.

@yuzefovich
Copy link
Member Author

Yes, the query you posted now works. I also tried a couple of others and found another edge case which my PR introduced, so I fixed that and added a few more logic tests.

I'm not sure under which category for release justification this would go though. It's a bug fix to existing functionality, but the bug is not of high priority/severity. I feel like "Category 4: Low risk, high benefit changes to existing functionality" is the most suitable, but I would not say I'm confident in this change since I think it is possible that there are some other edge cases I'm introducing which can result in an internal error while the current master would return the type mismatch error. Should this go in for 19.2?

@yuzefovich
Copy link
Member Author

I think it should be good to merge this now.

@yuzefovich
Copy link
Member Author

Friendly ping.

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

LGTM but:

  1. please remove the release justification line from the commit message

  2. please add a release note

Reviewed 4 of 4 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis)

Previously, the type checking code for a list of tuples expected that
all expressions in the list are actually tuples. Now we will also allow
for nulls to be present in the list.

Release note (sql change): NULLs are now allowed to be among tuples when
being compared against a tuple.
@yuzefovich
Copy link
Member Author

TFTRs!

bors r+

craig bot pushed a commit that referenced this pull request Oct 16, 2019
40298: tree: skip nulls when type checking a list of tuples r=yuzefovich a=yuzefovich

Previously, the type checking code for a list of tuples expected that
all expressions in the list are actually tuples. Now we will also allow
for nulls to be present in the list.

Fixes: #40297.

Release note (sql change): NULLs are now allowed to be among tuples when
being compared against a tuple.

41306: sql: add a clarifying comment about flow cleanup in distsql_running r=yuzefovich a=yuzefovich

Release note: None

Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Oct 16, 2019

Build succeeded

@craig craig bot merged commit 7fe1b19 into cockroachdb:master Oct 16, 2019
@yuzefovich yuzefovich deleted the fix-tuple branch November 12, 2019 23:47
@yuzefovich yuzefovich restored the fix-tuple branch November 12, 2019 23:47
@yuzefovich yuzefovich deleted the fix-tuple branch November 12, 2019 23:48
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.

sql: internal error: incompatible COALESCE expressions
4 participants