diff --git a/src/common/function/FunctionManager.cpp b/src/common/function/FunctionManager.cpp index 061a41113d..4d0775e53b 100644 --- a/src/common/function/FunctionManager.cpp +++ b/src/common/function/FunctionManager.cpp @@ -251,7 +251,8 @@ std::unordered_map> FunctionManager::typ {"date", {TypeSignature({}, Value::Type::DATE), TypeSignature({Value::Type::STRING}, Value::Type::DATE), - TypeSignature({Value::Type::MAP}, Value::Type::DATE)}}, + TypeSignature({Value::Type::MAP}, Value::Type::DATE), + TypeSignature({Value::Type::INT}, Value::Type::DATE)}}, {"datetime", {TypeSignature({}, Value::Type::DATETIME), TypeSignature({Value::Type::STRING}, Value::Type::DATETIME), @@ -1820,6 +1821,8 @@ FunctionManager::FunctionManager() { return Value::kNullBadData; } return result.value(); + } else if (args[0].get().isInt()) { + return time::TimeConversion::unixSecondsToDate(args[0].get().getInt()); } else { return Value::kNullBadType; } diff --git a/src/common/function/test/FunctionManagerTest.cpp b/src/common/function/test/FunctionManagerTest.cpp index babb1ef8b4..7600909d94 100644 --- a/src/common/function/test/FunctionManagerTest.cpp +++ b/src/common/function/test/FunctionManagerTest.cpp @@ -583,6 +583,7 @@ TEST_F(FunctionManagerTest, time) { TEST_FUNCTION( date, {Map({{"year", 2020}, {"month", 12}, {"day", 31}})}, Value(Date(2020, 12, 31))); } + { TEST_FUNCTION(date, {573206400}, Value(Date(1988, 3, 1))); } // leap year February days { // 2020 is leap @@ -1432,7 +1433,7 @@ TEST_F(FunctionManagerTest, returnType) { } // date { - auto result = FunctionManager::getReturnType("date", {Value::Type::INT}); + auto result = FunctionManager::getReturnType("date", {Value::Type::FLOAT}); ASSERT_FALSE(result.ok()); EXPECT_EQ(result.status().toString(), "Parameter's type error"); }