From 10c941c1087f3f4e24f505391fe30082b1020c6f Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Tue, 7 Jul 2026 12:49:20 -0700 Subject: [PATCH] fix: allow leading zeros in CAST(string AS INT64) The tryIntegerCast function had an explicit check rejecting any non-negative integer string starting with '0' (beyond just 0). This caused CAST('000012' AS INT64) to fail with a conversion exception, even though leading zeros are valid in integer representations. Removed the leading-zero restriction. The integerCastLoop digit parser handles leading zeros naturally. --- .../cast/functions/cast_string_non_nested_functions.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/include/function/cast/functions/cast_string_non_nested_functions.h b/src/include/function/cast/functions/cast_string_non_nested_functions.h index 550e845f5f..560406f6d6 100644 --- a/src/include/function/cast/functions/cast_string_non_nested_functions.h +++ b/src/include/function/cast/functions/cast_string_non_nested_functions.h @@ -233,10 +233,6 @@ inline bool tryIntegerCast(const char* input, uint64_t& len, IntegerCastData& return integerCastLoop(input, len, result); } - // not allow leading 0 - if (len > 1 && *input == '0') { - return false; - } return integerCastLoop(input, len, result); }