Copilot commented on code in PR #37241:
URL: https://github.com/apache/shardingsphere/pull/37241#discussion_r2575737251


##########
parser/sql/statement/core/src/main/java/org/apache/shardingsphere/sql/parser/statement/core/util/SQLUtils.java:
##########
@@ -66,21 +74,26 @@ public final class SQLUtils {
      */
     public static Number getExactlyNumber(final String value, final int radix) 
{
         try {
-            return getBigInteger(value, radix);
+            return getExactlyNumber(new BigInteger(value, radix));
         } catch (final NumberFormatException ex) {
             return new BigDecimal(value);
         }
     }
     
-    private static Number getBigInteger(final String value, final int radix) {
-        BigInteger result = new BigInteger(value, radix);
-        if (result.compareTo(new 
BigInteger(String.valueOf(Integer.MIN_VALUE))) >= 0 && result.compareTo(new 
BigInteger(String.valueOf(Integer.MAX_VALUE))) <= 0) {
-            return result.intValue();
+    /**
+     * Get exactly number.
+     *
+     * @param value to be converted value
+     * @return converted value
+     */
+    public static Number getExactlyNumber(final BigInteger value) {
+        if (value.compareTo(INTEGER_MIN) >= 0 && value.compareTo(INTEGER_MAX) 
<= 0) {
+            return value.intValue();
         }
-        if (result.compareTo(new BigInteger(String.valueOf(Long.MIN_VALUE))) 
>= 0 && result.compareTo(new BigInteger(String.valueOf(Long.MAX_VALUE))) <= 0) {
-            return result.longValue();
+        if (value.compareTo(LONG_MIN) >= 0 && value.compareTo(LONG_MAX) <= 0) {
+            return value.longValue();
         }
-        return result;
+        return value;
     }

Review Comment:
   The newly introduced public method `getExactlyNumber(BigInteger)` lacks 
direct test coverage. While it is indirectly tested through 
`getExactlyNumber(String, int)`, consider adding explicit test cases for this 
public API method to ensure it is thoroughly tested with various BigInteger 
inputs (e.g., boundary values for Integer and Long ranges).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to