Add SETOF support for PostgreSQL function return types#2217
Open
fmguerreiro wants to merge 3 commits intoapache:mainfrom
Open
Add SETOF support for PostgreSQL function return types#2217fmguerreiro wants to merge 3 commits intoapache:mainfrom
fmguerreiro wants to merge 3 commits intoapache:mainfrom
Conversation
b383eee to
829d0bf
Compare
iffyio
reviewed
Feb 19, 2026
src/ast/data_type.rs
Outdated
| /// e.g. `CREATE FUNCTION ... RETURNS SETOF text`. | ||
| /// | ||
| /// [PostgreSQL]: https://www.postgresql.org/docs/current/sql-createfunction.html | ||
| SetOf(Box<DataType>), |
Contributor
There was a problem hiding this comment.
would it make sense to represent this as a qualifier around the return type of a function instead? e.g.
enum FunctionReturnType {
DataType(DataType),
Setof(DataType)
}
CreateFunction { ... return_type: FunctionReturnType ... }Thinking that would probably be better because it would be a bit confusing having a SETOF DataType that isn't a valid data type in any dialect
829d0bf to
f82bb83
Compare
fmguerreiro
added a commit
to fmguerreiro/datafusion-sqlparser-rs
that referenced
this pull request
Feb 20, 2026
SETOF is a PostgreSQL-specific modifier for function return types, not a standalone data type. Introduce FunctionReturnType enum with DataType and SetOf variants, replacing DataType::SetOf. Addresses review feedback on apache#2217.
f82bb83 to
62385ea
Compare
fmguerreiro
added a commit
to fmguerreiro/datafusion-sqlparser-rs
that referenced
this pull request
Feb 20, 2026
SETOF is a PostgreSQL-specific modifier for function return types, not a standalone data type. Introduce FunctionReturnType enum with DataType and SetOf variants, replacing DataType::SetOf. Addresses review feedback on apache#2217.
SETOF is a PostgreSQL-specific modifier for function return types, not a standalone data type. Introduce FunctionReturnType enum with DataType and SetOf variants, replacing DataType::SetOf. Addresses review feedback on apache#2217.
62385ea to
11a37c6
Compare
iffyio
reviewed
Feb 20, 2026
| pub enum FunctionReturnType { | ||
| /// `RETURNS <type>` | ||
| DataType(DataType), | ||
| /// `RETURNS SETOF <type>` |
Contributor
There was a problem hiding this comment.
Can we instead move the link to the postgres docs here? since the enum itself applies to all dialects, whereas only this variant is pg specific
| } | ||
| } | ||
|
|
||
| impl Spanned for PartitionBoundValue { |
Contributor
There was a problem hiding this comment.
is there any changes in this diff (if not can we revert it)?
Comment on lines
+5887
to
+5888
| /// | ||
| /// Handles `RETURNS SETOF <type>` and plain `RETURNS <type>`. |
Contributor
There was a problem hiding this comment.
Suggested change
| /// | |
| /// Handles `RETURNS SETOF <type>` and plain `RETURNS <type>`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PostgreSQL functions can return sets via
RETURNS SETOF <type>. This is currently not supported by the parser, which fails when encounteringSETOFafterRETURNS.Changes
SETOFkeywordDataType::SetOf(Box<DataType>)variantSETOFinparse_data_type_helper()so anyDataType::SetOfround-trips through Display → parseExample
Reference