mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Merge pull request #62901 from KevinyhZou/fix_fromUnixTimestamp_beyond_uint32
Fix fromUnixtimestamp in joda syntax while the input value beyond UInt32
This commit is contained in:
commit
819b5aab55
@ -1169,7 +1169,10 @@ struct ToStartOfHourImpl
|
||||
struct ToYearImpl
|
||||
{
|
||||
static constexpr auto name = "toYear";
|
||||
|
||||
static UInt16 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toYear(t);
|
||||
}
|
||||
static UInt16 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toYear(t);
|
||||
@ -1217,7 +1220,10 @@ struct ToWeekYearImpl
|
||||
static constexpr auto name = "toWeekYear";
|
||||
|
||||
static constexpr Int8 week_mode = 3;
|
||||
|
||||
static UInt16 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toYearWeek(t, week_mode).first;
|
||||
}
|
||||
static UInt16 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toYearWeek(t, week_mode).first;
|
||||
@ -1241,7 +1247,10 @@ struct ToWeekYearImpl
|
||||
struct ToWeekOfWeekYearImpl
|
||||
{
|
||||
static constexpr auto name = "toWeekOfWeekYear";
|
||||
|
||||
static UInt16 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toISOWeek(t);
|
||||
}
|
||||
static UInt16 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toISOWeek(t);
|
||||
@ -1265,7 +1274,10 @@ struct ToWeekOfWeekYearImpl
|
||||
struct ToQuarterImpl
|
||||
{
|
||||
static constexpr auto name = "toQuarter";
|
||||
|
||||
static UInt8 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toQuarter(t);
|
||||
}
|
||||
static UInt8 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toQuarter(t);
|
||||
@ -1290,7 +1302,10 @@ struct ToQuarterImpl
|
||||
struct ToMonthImpl
|
||||
{
|
||||
static constexpr auto name = "toMonth";
|
||||
|
||||
static UInt8 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toMonth(t);
|
||||
}
|
||||
static UInt8 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toMonth(t);
|
||||
@ -1315,7 +1330,10 @@ struct ToMonthImpl
|
||||
struct ToDayOfMonthImpl
|
||||
{
|
||||
static constexpr auto name = "toDayOfMonth";
|
||||
|
||||
static UInt8 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toDayOfMonth(t);
|
||||
}
|
||||
static UInt8 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toDayOfMonth(t);
|
||||
@ -1341,7 +1359,10 @@ struct ToDayOfWeekImpl
|
||||
{
|
||||
static constexpr auto name = "toDayOfWeek";
|
||||
static constexpr bool value_may_be_string = true;
|
||||
|
||||
static UInt8 execute(UInt64 t, UInt8 mode, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toDayOfWeek(t, mode);
|
||||
}
|
||||
static UInt8 execute(Int64 t, UInt8 mode, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toDayOfWeek(t, mode);
|
||||
@ -1365,7 +1386,10 @@ struct ToDayOfWeekImpl
|
||||
struct ToDayOfYearImpl
|
||||
{
|
||||
static constexpr auto name = "toDayOfYear";
|
||||
|
||||
static UInt16 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toDayOfYear(t);
|
||||
}
|
||||
static UInt16 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toDayOfYear(t);
|
||||
@ -1421,7 +1445,10 @@ public:
|
||||
struct ToHourImpl
|
||||
{
|
||||
static constexpr auto name = "toHour";
|
||||
|
||||
static UInt8 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toHour(t);
|
||||
}
|
||||
static UInt8 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toHour(t);
|
||||
@ -1446,7 +1473,10 @@ struct ToHourImpl
|
||||
struct TimezoneOffsetImpl
|
||||
{
|
||||
static constexpr auto name = "timezoneOffset";
|
||||
|
||||
static time_t execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.timezoneOffset(t);
|
||||
}
|
||||
static time_t execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.timezoneOffset(t);
|
||||
@ -1474,7 +1504,10 @@ struct TimezoneOffsetImpl
|
||||
struct ToMinuteImpl
|
||||
{
|
||||
static constexpr auto name = "toMinute";
|
||||
|
||||
static UInt8 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toMinute(t);
|
||||
}
|
||||
static UInt8 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toMinute(t);
|
||||
@ -1499,7 +1532,10 @@ struct ToMinuteImpl
|
||||
struct ToSecondImpl
|
||||
{
|
||||
static constexpr auto name = "toSecond";
|
||||
|
||||
static UInt8 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toSecond(t);
|
||||
}
|
||||
static UInt8 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toSecond(t);
|
||||
@ -1550,7 +1586,10 @@ struct ToMillisecondImpl
|
||||
struct ToISOYearImpl
|
||||
{
|
||||
static constexpr auto name = "toISOYear";
|
||||
|
||||
static UInt16 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toISOYear(time_zone.toDayNum(t));
|
||||
}
|
||||
static UInt16 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toISOYear(time_zone.toDayNum(t));
|
||||
@ -1607,7 +1646,10 @@ struct ToStartOfISOYearImpl
|
||||
struct ToISOWeekImpl
|
||||
{
|
||||
static constexpr auto name = "toISOWeek";
|
||||
|
||||
static UInt8 execute(UInt64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toISOWeek(time_zone.toDayNum(t));
|
||||
}
|
||||
static UInt8 execute(Int64 t, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.toISOWeek(time_zone.toDayNum(t));
|
||||
|
@ -62,8 +62,8 @@ template <> struct InstructionValueTypeMap<DataTypeInt16> { using Instructi
|
||||
template <> struct InstructionValueTypeMap<DataTypeUInt16> { using InstructionValueType = UInt32; };
|
||||
template <> struct InstructionValueTypeMap<DataTypeInt32> { using InstructionValueType = UInt32; };
|
||||
template <> struct InstructionValueTypeMap<DataTypeUInt32> { using InstructionValueType = UInt32; };
|
||||
template <> struct InstructionValueTypeMap<DataTypeInt64> { using InstructionValueType = UInt32; };
|
||||
template <> struct InstructionValueTypeMap<DataTypeUInt64> { using InstructionValueType = UInt32; };
|
||||
template <> struct InstructionValueTypeMap<DataTypeInt64> { using InstructionValueType = Int64; };
|
||||
template <> struct InstructionValueTypeMap<DataTypeUInt64> { using InstructionValueType = UInt64; };
|
||||
template <> struct InstructionValueTypeMap<DataTypeDate> { using InstructionValueType = UInt16; };
|
||||
template <> struct InstructionValueTypeMap<DataTypeDate32> { using InstructionValueType = Int32; };
|
||||
template <> struct InstructionValueTypeMap<DataTypeDateTime> { using InstructionValueType = UInt32; };
|
||||
@ -1017,7 +1017,7 @@ public:
|
||||
else
|
||||
{
|
||||
for (auto & instruction : instructions)
|
||||
instruction.perform(pos, static_cast<UInt32>(vec[i]), 0, 0, *time_zone);
|
||||
instruction.perform(pos, static_cast<T>(vec[i]), 0, 0, *time_zone);
|
||||
}
|
||||
*pos++ = '\0';
|
||||
|
||||
@ -1073,7 +1073,7 @@ public:
|
||||
{
|
||||
/// DateTime/DateTime64 --> insert instruction
|
||||
/// Other types cannot provide the requested data --> write out template
|
||||
if constexpr (is_any_of<T, UInt32, Int64>)
|
||||
if constexpr (is_any_of<T, UInt32, Int64, UInt64>)
|
||||
{
|
||||
Instruction<T> instruction;
|
||||
instruction.setMysqlFunc(std::move(func));
|
||||
@ -1539,7 +1539,7 @@ public:
|
||||
/// If the argument was DateTime, add instruction for printing. If it was date, just append default literal
|
||||
auto add_instruction = [&]([[maybe_unused]] typename Instruction<T>::FuncJoda && func, [[maybe_unused]] const String & default_literal)
|
||||
{
|
||||
if constexpr (is_any_of<T, UInt32, Int64>)
|
||||
if constexpr (is_any_of<T, UInt32, Int64, UInt64>)
|
||||
{
|
||||
Instruction<T> instruction;
|
||||
instruction.setJodaFunc(std::move(func));
|
||||
|
@ -0,0 +1 @@
|
||||
2295-03-20 00:03:16
|
@ -0,0 +1 @@
|
||||
select fromUnixTimestampInJodaSyntax(10262736196, 'YYYY-MM-dd HH:mm:ss', 'Asia/Shanghai');
|
Loading…
Reference in New Issue
Block a user