[fix](timezone) fix timezone parse when there is no tzfile (#24578)
This commit is contained in:
@ -23,12 +23,12 @@
|
||||
|
||||
#include "common/status.h"
|
||||
#include "function_test_util.h"
|
||||
#include "gtest/gtest_pred_impl.h"
|
||||
#include "runtime/runtime_state.h"
|
||||
#include "testutil/any_type.h"
|
||||
#include "util/timezone_utils.h"
|
||||
#include "vec/core/types.h"
|
||||
#include "vec/data_types/data_type_date.h"
|
||||
#include "vec/data_types/data_type_date_time.h"
|
||||
#include "vec/data_types/data_type_nullable.h"
|
||||
#include "vec/data_types/data_type_number.h"
|
||||
#include "vec/data_types/data_type_string.h"
|
||||
#include "vec/data_types/data_type_time.h"
|
||||
@ -201,6 +201,62 @@ TEST(VTimestampFunctionsTest, timediff_test) {
|
||||
check_function<DataTypeTimeV2, true>(func_name, input_types, data_set);
|
||||
}
|
||||
|
||||
TEST(VTimestampFunctionsTest, convert_tz_test) {
|
||||
std::string func_name = "convert_tz";
|
||||
|
||||
ExecEnv* exec_env = ExecEnv::GetInstance();
|
||||
exec_env->_global_zone_cache = std::make_unique<vectorized::ZoneList>();
|
||||
auto test_state = RuntimeState::create_unique();
|
||||
test_state->set_exec_env(exec_env);
|
||||
TimezoneUtils::clear_timezone_names();
|
||||
|
||||
InputTypeSet input_types = {TypeIndex::DateTimeV2, TypeIndex::String, TypeIndex::String};
|
||||
|
||||
{
|
||||
DataSet data_set = {{{std::string {"2019-08-01 02:18:27"}, std::string {"Asia/SHANGHAI"},
|
||||
std::string {"america/Los_angeles"}},
|
||||
Null()}};
|
||||
check_function<DataTypeDateTimeV2, true>(func_name, input_types, data_set, false,
|
||||
test_state.get());
|
||||
}
|
||||
|
||||
{
|
||||
DataSet data_set = {{{std::string {"2019-08-01 02:18:27"}, std::string {"Asia/Shanghai"},
|
||||
std::string {"UTC"}},
|
||||
str_to_datetime_v2("2019-07-31 18:18:27", "%Y-%m-%d %H:%i:%s.%f")},
|
||||
{{std::string {"2019-08-01 02:18:27"}, std::string {"Asia/Shanghai"},
|
||||
std::string {"Utc"}},
|
||||
Null()},
|
||||
{{std::string {"2019-08-01 02:18:27"}, std::string {"Asia/Shanghai"},
|
||||
std::string {"UTC"}},
|
||||
str_to_datetime_v2("2019-07-31 18:18:27", "%Y-%m-%d %H:%i:%s.%f")},
|
||||
{{std::string {"2019-08-01 02:18:27"}, std::string {"Asia/SHANGHAI"},
|
||||
std::string {"america/Los_angeles"}},
|
||||
Null()}};
|
||||
check_function<DataTypeDateTimeV2, true>(func_name, input_types, data_set, false,
|
||||
test_state.get());
|
||||
}
|
||||
|
||||
{
|
||||
DataSet data_set = {{{std::string {"2019-08-01 02:18:27"}, std::string {"Asia/Shanghai"},
|
||||
std::string {"UTC"}},
|
||||
str_to_datetime_v2("2019-07-31 18:18:27", "%Y-%m-%d %H:%i:%s.%f")},
|
||||
{{std::string {"2019-08-01 02:18:27"}, std::string {"Asia/Shanghai"},
|
||||
std::string {"Utc"}},
|
||||
str_to_datetime_v2("2019-07-31 18:18:27", "%Y-%m-%d %H:%i:%s.%f")},
|
||||
{{std::string {"2019-08-01 02:18:27"}, std::string {"Asia/Shanghai"},
|
||||
std::string {"UTC"}},
|
||||
str_to_datetime_v2("2019-07-31 18:18:27", "%Y-%m-%d %H:%i:%s.%f")},
|
||||
{{std::string {"2019-08-01 02:18:27"}, std::string {"Asia/SHANGHAI"},
|
||||
std::string {"america/Los_angeles"}},
|
||||
str_to_datetime_v2("2019-07-31 11:18:27", "%Y-%m-%d %H:%i:%s.%f")}};
|
||||
TimezoneUtils::load_timezone_names();
|
||||
TimezoneUtils::load_timezones_to_cache(*exec_env->_global_zone_cache);
|
||||
check_function<DataTypeDateTimeV2, true>(func_name, input_types, data_set, false,
|
||||
test_state.get());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(VTimestampFunctionsTest, date_format_test) {
|
||||
std::string func_name = "date_format";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user