dolthub / dolthub/dolt

`GREATEST` and `LEAST` functions should return decimal type when args are decimal types

Open
#10,567 2 comments 0 reactions 0 assignees View on GitHub
bug correctness
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

Allowing decimal type arguments (#10562) was implemented in dolthub/go-mysql-server#3447 but the return type is a float64 when it should be a decimal of the highest precision.
```sql
mysql> create table t(a decimal(6, 2), b decimal(8, 5), c decimal(5, 1));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t values (2.75, 8.8, 3.1);
Query OK, 1 row affected (0.01 sec)

mysql> select greatest(a, b, c), least(a, b, c) from t;
+-------------------+----------------+
| greatest(a, b, c) | least(a, b, c) |
+-------------------+----------------+
| 8.80000 | 2.75000 |
+-------------------+----------------+
1 row in set (0.00 sec)
```

We also need to consider scale and when the argument types are mixed.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.