dolthub / dolthub/dolt

`time` precision is not respected

Open
#10,661 0 comments 0 reactions 0 assignees View on GitHub
correctness enhancement sql
Dominant language
Go
Stars
24.5k
Forks
873
Avg merge
1d 8h
Merged PRs (30d)
120

Description

It seems like the `time` type is hardcoded to always be `time(6)`. We need to update the `time` type to respect the actual precision.

Dolt
```
tmp/main*> SELECT CAST('12:34:56.123456' AS TIME);
+---------------------------------+
| CAST('12:34:56.123456' AS TIME) |
+---------------------------------+
| 12:34:56.123456 |
+---------------------------------+
1 row in set (0.00 sec)

tmp/main*> select cast('12:34:56.123' as time(1));
+---------------------------------+
| cast('12:34:56.123' as time(1)) |
+---------------------------------+
| 12:34:56.123000 |
+---------------------------------+
1 row in set (0.00 sec)
```

MySQL
```
mysql> SELECT CAST('12:34:56.123456' AS TIME);
+---------------------------------+
| CAST('12:34:56.123456' AS TIME) |
+---------------------------------+
| 12:34:56 |
+---------------------------------+
1 row in set (0.00 sec)

mysql> select cast('12:34:56.123' as time(1));
+---------------------------------+
| cast('12:34:56.123' as time(1)) |
+---------------------------------+
| 12:34:56.1 |
+---------------------------------+
1 row in set (0.00 sec)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the two CAST examples from the issue, then locate the time type and CAST handling in the SQL implementation. Compare the results with the documented MySQL behavior; done means TIME preserves default precision and applies the requested precision such as TIME(1).

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.