Skip to content

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

Merged
Mytherin merged 6 commits into
duckdb:mainfrom
Mytherin:scalarsubquery
Aug 23, 2024
Merged

Mytherin merged 6 commits into
duckdb:mainfrom
Mytherin:scalarsubquery

Conversation

@Mytherin

Copy link
Copy Markdown
Member

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
@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 <[email protected]>
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