mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 07:01:59 +00:00
Fixed another inconsistency in partition names
This commit is contained in:
parent
d1eaa34cd9
commit
860e9092f1
@ -133,7 +133,10 @@ DateLUTImpl::DateLUTImpl(const std::string & time_zone_)
|
||||
}
|
||||
|
||||
/// Fill lookup table for years and months.
|
||||
for (size_t day = 0; day < DATE_LUT_SIZE && lut[day].year <= DATE_LUT_MAX_YEAR; ++day)
|
||||
size_t year_months_lut_index = 0;
|
||||
size_t first_day_of_last_month = 0;
|
||||
|
||||
for (size_t day = 0; day < DATE_LUT_SIZE; ++day)
|
||||
{
|
||||
const Values & values = lut[day];
|
||||
|
||||
@ -141,7 +144,16 @@ DateLUTImpl::DateLUTImpl(const std::string & time_zone_)
|
||||
{
|
||||
if (values.month == 1)
|
||||
years_lut[values.year - DATE_LUT_MIN_YEAR] = day;
|
||||
years_months_lut[(values.year - DATE_LUT_MIN_YEAR) * 12 + values.month - 1] = day;
|
||||
|
||||
year_months_lut_index = (values.year - DATE_LUT_MIN_YEAR) * 12 + values.month - 1;
|
||||
years_months_lut[year_months_lut_index] = day;
|
||||
first_day_of_last_month = day;
|
||||
}
|
||||
}
|
||||
|
||||
/// Fill the rest of lookup table with the same last month (2106-02-01).
|
||||
for (; year_months_lut_index < DATE_LUT_YEARS * 12; ++year_months_lut_index)
|
||||
{
|
||||
years_months_lut[year_months_lut_index] = first_day_of_last_month;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
/// Table size is bigger than DATE_LUT_MAX_DAY_NUM to fill all indices within UInt16 range: this allows to remove extra check.
|
||||
#define DATE_LUT_SIZE 0x10000
|
||||
#define DATE_LUT_MIN_YEAR 1970
|
||||
#define DATE_LUT_MAX_YEAR 2105 /// Last supported year
|
||||
#define DATE_LUT_MAX_YEAR 2106 /// Last supported year (incomplete)
|
||||
#define DATE_LUT_YEARS (1 + DATE_LUT_MAX_YEAR - DATE_LUT_MIN_YEAR) /// Number of years in lookup table
|
||||
|
||||
#if defined(__PPC__)
|
||||
|
@ -120,8 +120,8 @@ void MergeTreePartInfo::parseMinMaxDatesFromPartName(const String & part_name, D
|
||||
min_date = date_lut.YYYYMMDDToDayNum(min_yyyymmdd);
|
||||
max_date = date_lut.YYYYMMDDToDayNum(max_yyyymmdd);
|
||||
|
||||
DayNum min_month = date_lut.toFirstDayNumOfMonth(min_date);
|
||||
DayNum max_month = date_lut.toFirstDayNumOfMonth(max_date);
|
||||
auto min_month = date_lut.toNumYYYYMM(min_date);
|
||||
auto max_month = date_lut.toNumYYYYMM(max_date);
|
||||
|
||||
if (min_month != max_month)
|
||||
throw Exception("Part name " + part_name + " contains different months", ErrorCodes::BAD_DATA_PART_NAME);
|
||||
|
Loading…
Reference in New Issue
Block a user