From 3595a22dfd8b3349d398d157545616bbe9f57a4f Mon Sep 17 00:00:00 2001 From: Jerry Hu Date: Thu, 1 Dec 2022 16:36:33 +0800 Subject: [PATCH] [fix](function) StringRef should not be key of timezone cache --- be/src/vec/functions/function_convert_tz.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/be/src/vec/functions/function_convert_tz.h b/be/src/vec/functions/function_convert_tz.h index 9d6f1e755d4419..65a3ced45f4135 100644 --- a/be/src/vec/functions/function_convert_tz.h +++ b/be/src/vec/functions/function_convert_tz.h @@ -26,7 +26,7 @@ namespace doris::vectorized { struct ConvertTzCtx { - std::map time_zone_cache; + std::map time_zone_cache; }; class FunctionConvertTZ : public IFunction { public: @@ -102,7 +102,7 @@ class FunctionConvertTZ : public IFunction { size_t input_rows_count) { auto convert_ctx = reinterpret_cast( context->get_function_state(FunctionContext::FunctionStateScope::THREAD_LOCAL)); - std::map time_zone_cache_; + std::map time_zone_cache_; auto& time_zone_cache = convert_ctx ? convert_ctx->time_zone_cache : time_zone_cache_; for (size_t i = 0; i < input_rows_count; i++) { if (result_null_map[i]) { @@ -110,12 +110,11 @@ class FunctionConvertTZ : public IFunction { continue; } - StringRef from_tz = from_tz_column->get_data_at(i); - StringRef to_tz = to_tz_column->get_data_at(i); + auto from_tz = from_tz_column->get_data_at(i).to_string(); + auto to_tz = to_tz_column->get_data_at(i).to_string(); if (time_zone_cache.find(from_tz) == time_zone_cache.cend()) { - if (!TimezoneUtils::find_cctz_time_zone(from_tz.to_string(), - time_zone_cache[from_tz])) { + if (!TimezoneUtils::find_cctz_time_zone(from_tz, time_zone_cache[from_tz])) { result_null_map[i] = true; result_column->insert_default(); continue; @@ -123,8 +122,7 @@ class FunctionConvertTZ : public IFunction { } if (time_zone_cache.find(to_tz) == time_zone_cache.cend()) { - if (!TimezoneUtils::find_cctz_time_zone(to_tz.to_string(), - time_zone_cache[to_tz])) { + if (!TimezoneUtils::find_cctz_time_zone(to_tz, time_zone_cache[to_tz])) { result_null_map[i] = true; result_column->insert_default(); continue;