Skip to content

Make Date larger then 2106-02-07 overflow as 0(1970-01-01)#18565

Merged
CurtizJ merged 2 commits intoClickHouse:masterfrom
hexiaoting:dev_date
Dec 30, 2020
Merged

Make Date larger then 2106-02-07 overflow as 0(1970-01-01)#18565
CurtizJ merged 2 commits intoClickHouse:masterfrom
hexiaoting:dev_date

Conversation

@hexiaoting
Copy link
Copy Markdown
Contributor

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Fix previous bug when date overflow with different values.
Strict Date value limit to "2106-02-07", cast date > "2106-02-07" to value 0.

Detailed description / Documentation draft:

Previous bug:

dell123 :) create table dt_overflow(d Date, i int) engine MergeTree partition by d order by i;

CREATE TABLE dt_overflow
(
    `d` Date,
    `i` int
)
ENGINE = MergeTree
PARTITION BY d
ORDER BY i

Query id: db7e8b24-f7d1-4fed-a20b-6d79e8249e70

Ok.

0 rows in set. Elapsed: 0.048 sec.

dell123 :) insert into dt_overflow values('2106-11-11', 1);

INSERT INTO dt_overflow VALUES

Query id: 0574a991-158a-4cc4-88d7-ef7fa39c0d88

Ok.

1 rows in set. Elapsed: 0.005 sec.

dell123 :) select * from dt_overflow;

SELECT *
FROM dt_overflow

Query id: c9d2111e-d79d-4d18-85ea-043c24f96f5f

┌──────────d─┬─i─┐
│ 2106-02-07 │ 1 │
└────────────┴───┘

1 rows in set. Elapsed: 0.003 sec.

dell123 :) insert into dt_overflow values('2106-11-12', 1);

INSERT INTO dt_overflow VALUES

Query id: 005e5882-89fe-47d0-84ee-878fb28ecbf8


Received exception from server (version 20.13.1):
Code: 246. DB::Exception: Received from localhost:9000. DB::Exception: Partition value mismatch between two parts with the same partition ID. Existing part: 21060207_1_1_0, newly added part: 21060207_2_2_0.

1 rows in set. Elapsed: 0.385 sec.

dell123 :)

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Dec 28, 2020
@CurtizJ CurtizJ self-assigned this Dec 29, 2020
return DayNum(0); // TODO (nemkov, DateTime64 phase 2): implement creating real date for year outside of LUT range.

// The day after 2106-02-07 will not stored fully as struct Values, so just overflow it as 0
if (unlikely(year == DATE_LUT_MAX_YEAR && (month > 2 || day_of_month > 7)))
Copy link
Copy Markdown
Member

@CurtizJ CurtizJ Dec 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this condition is not correct. It will overflow also all dates in [2106-01-08; 2106-01-31].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O, yes, it's wrong, I will fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants