Skip to content

Datatype Date32, support range 1925 to 2283#25774

Merged
kssenii merged 25 commits intoClickHouse:masterfrom
liuneng1994:datatype-date32
Jul 12, 2021
Merged

Datatype Date32, support range 1925 to 2283#25774
kssenii merged 25 commits intoClickHouse:masterfrom
liuneng1994:datatype-date32

Conversation

@liuneng1994
Copy link
Copy Markdown
Contributor

@liuneng1994 liuneng1994 commented Jun 28, 2021

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

Changelog category (leave one):

  • New Feature

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

Add a new datatype Date32 (store data as Int32), support date range same with Datetime64
support load parquet date32 to ClickHouse Date32
Add new function toDate32 like toDate
Support some function :

  • toYear
  • toMonth
  • toQuarter
  • toDayOfMonth
  • toDayOfWeek
  • toDayOfYear
  • toStartOfDay
  • toMonday
  • toISOWeek
  • toISOYear
  • toWeek
  • toYearWeek
  • toStartOfWeek
  • toStartOfMonth
  • toStartOfQuarter
  • toStartOfYear
  • toStartOfISOYear
  • toRelativeYearNum
  • toRelativeQuarterNum
  • toRelativeMonthNum
  • toRelativeWeekNum
  • toRelativeDayNum
  • toRelativeHourNum
  • toRelativeMinuteNum
  • toRelativeSecondNum
  • toYYYYMM
  • toYYYYMMDD
  • toYYYYMMDDhhmmss
  • addSeconds
  • addMinutes
  • addHours
  • addDays
  • addWeeks
  • addMonths
  • addQuarters
  • addYears
  • subtractSeconds
  • subtractMinutes
  • subtractHours
  • subtractDays
  • subtractWeeks
  • subtractMonths
  • subtractQuarters
  • subtractYears

Detailed description / Documentation draft:

I will add more docs in the future

Information about CI checks: https://clickhouse.tech/docs/en/development/continuous-integration/

@robot-clickhouse robot-clickhouse added doc-alert pr-feature Pull request with new product feature labels Jun 28, 2021
@liuneng1994 liuneng1994 changed the title Datatype date32 Datatype Date32, support range 1925 to 2283 Jun 28, 2021
@liuneng1994
Copy link
Copy Markdown
Contributor Author

retest this please

@kssenii kssenii self-assigned this Jul 2, 2021
@liuneng1994
Copy link
Copy Markdown
Contributor Author

liuneng1994 commented Jul 5, 2021

@kssenii I fix some functional tests.There are still two failure cases, but they seem to have nothing to do with my code. And AST fuzzer failed, I didn't change the wrong line of code. I don't know how to fix it

@kssenii
Copy link
Copy Markdown
Member

kssenii commented Jul 5, 2021

Ok! I'll try to review as soon as I can (most likely tomorrow).

@liuneng1994 liuneng1994 closed this Jul 7, 2021
@liuneng1994 liuneng1994 reopened this Jul 7, 2021
@kssenii
Copy link
Copy Markdown
Member

kssenii commented Jul 8, 2021

I think that here

inline ExtendedDayNum NO_SANITIZE_UNDEFINED addMonths(ExtendedDayNum d, Int64 delta) const
{
return toDayNum(addMonthsIndex(d, delta));
}
inline Time NO_SANITIZE_UNDEFINED addQuarters(Time t, Int64 delta) const
{
return addMonths(t, delta * 3);
}

data types need to be adjusted (hint from fuzzer ../base/common/../common/DateLUTImpl.h:1173:35: runtime error), the max now will be Int32 after adding Date32, there is no need in int64. Lets make it Int32 in methods which then call inside addMonths. Please, check similar places there.

@liuneng1994
Copy link
Copy Markdown
Contributor Author

I think that here

inline ExtendedDayNum NO_SANITIZE_UNDEFINED addMonths(ExtendedDayNum d, Int64 delta) const
{
return toDayNum(addMonthsIndex(d, delta));
}
inline Time NO_SANITIZE_UNDEFINED addQuarters(Time t, Int64 delta) const
{
return addMonths(t, delta * 3);
}

data types need to be adjusted (hint from fuzzer ../base/common/../common/DateLUTImpl.h:1173:35: runtime error), the max now will be Int32 after adding Date32, there is no need in int64. Lets make it Int32 in methods which then call inside addMonths. Please, check similar places there.

I fix this issue, fuzzer test is ok

@liuneng1994 liuneng1994 requested a review from kssenii July 9, 2021 10:31
@kssenii
Copy link
Copy Markdown
Member

kssenii commented Jul 9, 2021

Also please run ClickHouse/utils/generate-ya-make/generate-ya-make.sh script to fix Yandex third-party checks . It will add some changes to ya.make files.

@liuneng1994
Copy link
Copy Markdown
Contributor Author

Also please run ClickHouse/utils/generate-ya-make/generate-ya-make.sh script to fix Yandex third-party checks . It will add some changes to ya.make files.

I have run this script, but third-party checks still fail

@liuneng1994
Copy link
Copy Markdown
Contributor Author

@kssenii failed again...

@kssenii
Copy link
Copy Markdown
Member

kssenii commented Jul 12, 2021

Yandex third-party checks (only for Yandex employees) failure not related to changes, its broken in master: Code: 46. DB::Exception: Received from localhost:38565. DB::Exception: Unknown function h3ToChildren: While processing h3ToChildren(599405990164561919, 100).

@gyuton
Copy link
Copy Markdown
Contributor

gyuton commented Jul 15, 2021

Internal documentation ticket: DOCSUP-11585.

@alexey-milovidov
Copy link
Copy Markdown
Member

@kssenii One bug was found: #26351
I will revert this PR before the bug will be fixed.

@liuneng1994
Copy link
Copy Markdown
Contributor Author

liuneng1994 commented Jul 28, 2021

I found that my github id disappeared from the code base. This is a sad story. @kssenii

@alexey-milovidov
Copy link
Copy Markdown
Member

@liuneng1994 Your commits are recorded:

milovidov@milovidov-desktop:~/work/ClickHouse$ git log | grep 'neng.liu'
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>

And you will appear in the system.contributors table and in the authors in changelog.
The full history of development is kept, including your commits, revert and revert of revert.

@liuneng1994
Copy link
Copy Markdown
Contributor Author

@liuneng1994 Your commits are recorded:

milovidov@milovidov-desktop:~/work/ClickHouse$ git log | grep 'neng.liu'
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>
Author: neng.liu <[email protected]>
Author: Neng Liu <[email protected]>

And you will appear in the system.contributors table and in the authors in changelog.
The full history of development is kept, including your commits, revert and revert of revert.

OK, thanks very much

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

Labels

pr-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants