Skip to content

Return an error when multiple rows are returned from a scalar subquery #13514

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

Merged
merged 6 commits into from
Aug 23, 2024

Conversation

Mytherin
Copy link
Collaborator

Implements #11521
Implements #13469

This PR modifies the behavior of scalar subqueries so that an error is thrown when multiple rows are returned, instead of returning a random row. This aligns the behavior of the system with that of Postgres, instead of that of SQLite.

For example:

select (select unnest(range(10)));
-- Invalid Input Error: More than one row returned by a subquery used as an expression - scalar subqueries can only return a single row.

The old behavior is available through the scalar_subquery_error_on_multiple_rows configuration setting:

SET scalar_subquery_error_on_multiple_rows=false;
D select (select unnest(range(10))) as result;
┌────────┐
│ result │
│ int64  │
├────────┤
│      0 │
└────────┘

@duckdb-draftbot duckdb-draftbot marked this pull request as draft August 22, 2024 15:48
@Mytherin Mytherin marked this pull request as ready for review August 22, 2024 15:49
@duckdb-draftbot duckdb-draftbot marked this pull request as draft August 23, 2024 08:34
@Mytherin Mytherin marked this pull request as ready for review August 23, 2024 08:34
@Mytherin Mytherin merged commit 7abb706 into duckdb:main Aug 23, 2024
39 checks passed
@Mytherin Mytherin deleted the scalarsubquery branch August 28, 2024 14:02
github-actions bot pushed a commit to duckdb/duckdb-r that referenced this pull request Sep 7, 2024
Merge pull request duckdb/duckdb#13514 from Mytherin/scalarsubquery
github-actions bot added a commit to duckdb/duckdb-r that referenced this pull request Sep 7, 2024
Merge pull request duckdb/duckdb#13514 from Mytherin/scalarsubquery

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Documentation Use for issues or PRs that require changes in the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant