Add SMALLEST and LARGEST functions in PyDough #226
Labels
documentation
Improvements or additions to documentation
effort - low
quick & simple issue
enhancement
New feature or request
user feature
Adding a new user-facing feature/functionality
Goal: add a functions to PyDough with the following functionalities, which should be tested e2e (see
test_pipeline.py
for examples):SMALLEST(X, Y, ...)
is equivalent to the SQL functionLEAST(X, Y, ...)
, or the Pythonmin
function when called on results from each record (as opposed to be being used as an aggregation).LARGEST(X, Y, ...)
is equivalent to the SQL functionGREATEST(X, Y, ...)
, or the Pythonmax
function when called on results from each record (as opposed to be being used as an aggregation).Not every SQL dialect has
LEAST
orGREATEST
, but the ones that don't generally allowMIN
orMAX
to take in 2+ arguments (in which case they do this behavior instead of aggregation). The way to handle this in SQLGlot is to convert to a 2+ argument call toMIN
orMAX
. For ANSI, a fallback convert to a convoluted CASE statement can be done (e.g.LEAST(a, b, c)
=>CASE WHEN a <= LEAST(b, c) THEN a ELSE LEAST(b, c) END
withLEAST(b, c)
recursively transformed in a similar manner). Both functions should throw an error if called on <2 arguments.These features need to be documented in the function list documentation
The text was updated successfully, but these errors were encountered: