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

sql: fix panic with null delimiter in string_agg #28837

Merged
merged 1 commit into from
Aug 20, 2018

Conversation

jordanlewis
Copy link
Member

Closes #28836.

Release note: None

@jordanlewis jordanlewis requested review from justinj, BramGruneir and a team August 20, 2018 16:12
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@BramGruneir BramGruneir left a comment

Choose a reason for hiding this comment

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

Nice catch!

Please add a logic test for this.

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/sem/builtins/aggregate_builtins.go, line 642 at r1 (raw file):

	// via the first element in others.
	if len(others) == 1 {
		if others[0] == tree.DNull {

This behaviour is incorrect. In postgres, using a NULL in both a window function or normal aggregate, the result is to treat it as an empty delimiter.

@jordanlewis
Copy link
Member Author

I added a logic test containing this massive query that caught the bug. I actually can't figure out how to reproduce with just a simple window function! Maybe we could sit together and look at it?

@jordanlewis
Copy link
Member Author

Reduced the test case. PTAL

Copy link
Member

@BramGruneir BramGruneir 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 2 of 2 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale)

@jordanlewis
Copy link
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Aug 20, 2018
28837: sql: fix panic with null delimiter in string_agg r=jordanlewis a=jordanlewis

Closes #28836.

Release note: None

Co-authored-by: Jordan Lewis <[email protected]>
@craig
Copy link
Contributor

craig bot commented Aug 20, 2018

Build succeeded

@craig craig bot merged commit 8900d13 into cockroachdb:master Aug 20, 2018
@jordanlewis jordanlewis deleted the fix-null-concat-agg branch August 20, 2018 20:03
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