From 7196ea1ea8ea92bf25201362eea019e6d5bc36cc Mon Sep 17 00:00:00 2001 From: Andy Grove Date: Sun, 28 Apr 2024 16:59:56 -0600 Subject: [PATCH] fix regression --- .../execution/datafusion/expressions/cast.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/core/src/execution/datafusion/expressions/cast.rs b/core/src/execution/datafusion/expressions/cast.rs index 861b698a9..f6edb1cdd 100644 --- a/core/src/execution/datafusion/expressions/cast.rs +++ b/core/src/execution/datafusion/expressions/cast.rs @@ -320,18 +320,23 @@ fn do_cast_string_to_int< let positive = ch == '+'; parsed_sign = true; if negative || positive { + if i + 1 == len { + // input string is just "+" or "-" + return none_or_err(eval_mode, type_name, str); + } // consume this char continue; - } else if i + 1 == len { - return none_or_err(eval_mode, type_name, str); } } - if ch == '.' && eval_mode == EvalMode::Legacy { - // truncate decimal in legacy mode - state = State::ParseFractionalDigits; - // consume this char - continue; + if ch == '.' { + if eval_mode == EvalMode::Legacy { + // truncate decimal in legacy mode + state = State::ParseFractionalDigits; + continue; + } else { + return none_or_err(eval_mode, type_name, str); + } } let digit = if ch.is_ascii_digit() {