ClickHouse / ClickHouse/ClickHouse
Convert overflow Serializing DateTime64 < epoch to Protobuf
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 21h 32m
- Merged PRs (30d)
- 515
Description
### Company or project name
ClickHouse
### Describe what's wrong
Attempting to serialize a DateTime64 prior to 1970-01-01 to Protobuf throws a Convert overflow error.
### Does it reproduce on the most recent release?
Yes
### How to reproduce
```
:) INSERT INTO FUNCTION file('test.tmp', 'Protobuf', 't DateTime64(6)') SETTINGS date_time_output_format='iso', engine_file_truncate_on_insert=1 FORMAT TSV
1969-01-01 00:00:00+00
Received exception:
Code: 407. DB::Exception: Convert overflow. (DECIMAL_OVERFLOW)
:) INSERT INTO FUNCTION file('test.tmp', 'Protobuf', 't DateTime64(6)') SETTINGS date_time_output_format='iso', engine_file_truncate_on_insert=1 FORMAT TSV
1970-01-01 00:00:00+00
Ok.
```
### Expected behavior
I would think that the Protobuf Timestamp type can handle dates before the epoch. If not, perhaps refuse to attempt to serialize if the timestamp is out of range.
### Error message and/or stacktrace
Code: 407. DB::Exception: Convert overflow. (DECIMAL_OVERFLOW)
### Related issues and pull requests
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start by running the supplied INSERT statements against the Protobuf file output path and compare the pre-epoch and epoch results. Trace the DateTime64-to-Protobuf Timestamp conversion involved in that path; done means dates before 1970 serialize successfully, or out-of-range values are rejected with a clear, intentional error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 63/100