-
-
Notifications
You must be signed in to change notification settings - Fork 39
array_agg support and general framework for postgres aggregate functions #1497
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
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
94989f7
Scaffolding for new aggregation funcs
zachmu 421bd81
sketching out compiled agg funcs
zachmu c1e70b5
removing more unneeded override funcs
zachmu a2b9e74
checkpoint
zachmu 8dad3ee
Postgres agg func determination
zachmu f7e4f97
Pulled out more aggregate func methods, did some renaming of poorly n…
zachmu c50eb4c
Removed unused var and functionality
zachmu 6923b1c
Couple typos, almost working
zachmu 20c57b9
Bug fix
zachmu 8f91f1f
Fully working POC
zachmu 9cbe7b8
Moved array_agg into a new package
zachmu acb9965
new test methods
zachmu 8e2150f
Added skipped test
zachmu f7d39ac
Formatting
zachmu c75142b
new gms
zachmu 019c668
merge main
zachmu 5bfa72a
latest gms
zachmu 85abf36
Some missing docs and simplifications
zachmu e450b5c
new gms
zachmu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright 2025 Dolthub, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package aggregate | ||
|
|
||
| import ( | ||
| "github.com/dolthub/go-mysql-server/sql" | ||
|
|
||
| "github.com/dolthub/doltgresql/server/functions/framework" | ||
| pgtypes "github.com/dolthub/doltgresql/server/types" | ||
| ) | ||
|
|
||
| // initArrayAgg registers the functions to the catalog. | ||
| func initArrayAgg() { | ||
| framework.RegisterAggregateFunction(array_agg) | ||
| } | ||
|
|
||
| // array_agg represents the PostgreSQL array_agg function. | ||
| var array_agg = framework.Func1Aggregate{ | ||
| Function1: framework.Function1{ | ||
| Name: "array_agg", | ||
| Return: pgtypes.AnyArray, | ||
| Parameters: [1]*pgtypes.DoltgresType{ | ||
| pgtypes.AnyElement, | ||
| }, | ||
| Callable: func(ctx *sql.Context, paramsAndReturn [2]*pgtypes.DoltgresType, val1 any) (any, error) { | ||
| return nil, nil | ||
| }, | ||
| }, | ||
| NewAggBuffer: newArrayAggBuffer, | ||
| } | ||
|
|
||
| type arrayAggBuffer struct { | ||
| elements []any | ||
| } | ||
|
|
||
| func newArrayAggBuffer() (sql.AggregationBuffer, error) { | ||
| return &arrayAggBuffer{ | ||
| elements: make([]any, 0), | ||
| }, nil | ||
| } | ||
|
|
||
| func (a *arrayAggBuffer) Dispose() {} | ||
|
|
||
| func (a *arrayAggBuffer) Eval(context *sql.Context) (interface{}, error) { | ||
| if len(a.elements) == 0 { | ||
| return nil, nil | ||
| } | ||
| return a.elements, nil | ||
| } | ||
|
|
||
| func (a *arrayAggBuffer) Update(ctx *sql.Context, row sql.Row) error { | ||
| a.elements = append(a.elements, row[0]) | ||
| return nil | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // Copyright 2025 Dolthub, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package aggregate | ||
|
|
||
| func Init() { | ||
| initArrayAgg() | ||
| } |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.