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

Add implementation of the LEAST/GREATEST functions #698

Merged
merged 2 commits into from Jun 23, 2020
Merged

Conversation

Mytherin
Copy link
Collaborator

This PR adds the LEAST/GREATEST functions (#697), examples:

SELECT LEAST(1, 3); -- 1
SELECT LEAST(1, 3, 0); -- 0
SELECT LEAST(1, 3, 0, NULL); -- NULL

LEAST/GREATEST are varargs functions, meaning they accept any number of parameters.

The MySQL variant is implemented, which means that any NULL present results in a NULL as output. The PostgreSQL variant has different behavior here - it ignores any NULL values (similar to CONCAT). I have no strong opinion either way, the MySQL one made a bit more sense to me, but we can change this around if preferred.

The implementation was a bit less straightforward than normal as the Postgres parser had the LEAST/GREATEST hardcoded in rather than as a normal function - no clue why, I have removed this and turned it into a normal function.

@Mytherin Mytherin merged commit 97258fc into master Jun 23, 2020
@hannes hannes deleted the leastgreatest branch June 26, 2020 07:57
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.

None yet

1 participant