When I try to use the min scalar function e.g.
select min(distance, 5)
from courses limit 10
It instead uses the aggregation function. i.e. it finds the minimum value across all rows, rather than computing the minimum value of distance and 5 per row

If I would use the function with some hardcoded values then it does pick the correct function:
select min(7, 5)
from courses limit 10

The same issue is there for the max function as well.