Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions be/src/util/string_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,11 @@ T StringParser::string_to_int_internal(const char* __restrict s, int len, ParseR
[[fallthrough]];
case '+':
++i;
// only one '+'/'-' char, so could return failure directly
if (UNLIKELY(len == 1)) {
*result = PARSE_FAILURE;
return 0;
}
}

// This is the fast path where the string cannot overflow.
Expand Down
12 changes: 12 additions & 0 deletions regression-test/data/datatype_p0/json/json_cast.out
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,15 @@ true
-- !sql14 --
1.1111

-- !sql15 --
\N

-- !sql16 --
\N

-- !sql17 --
\N

-- !sql18 --
\N

6 changes: 5 additions & 1 deletion regression-test/suites/datatype_p0/json/json_cast.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// under the License.

suite("test_json_type_cast", "p0") {
sql """ set enable_fold_constant_by_be = false;"""
qt_sql1 "SELECT CAST(CAST(10 AS JSON) as INT)"
qt_sql2 "SELECT CAST(CAST(102423 AS JSON) as TINYINT)"
qt_sql3 "SELECT CAST(CAST(102423 AS JSON) as SMALLINT)"
Expand All @@ -32,4 +31,9 @@ suite("test_json_type_cast", "p0") {
qt_sql12 """select cast("111111" as json)"""
qt_sql13 """select cast(111111 as json)"""
qt_sql14 """select cast(1.1111 as json)"""

qt_sql15 """select cast("+" as int);"""
qt_sql16 """select cast("-" as int);"""
qt_sql17 """select cast("a" as int);"""
qt_sql18 """select cast("/" as int);"""
}