You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/11/12 09:50:56 UTC

[GitHub] [spark] AngersZhuuuu commented on a change in pull request #30350: [SPARK-33428][SQL] Conv UDF use BigInt to avoid Long value overflow

AngersZhuuuu commented on a change in pull request #30350:
URL: https://github.com/apache/spark/pull/30350#discussion_r521974807



##########
File path: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/MathExpressionsSuite.scala
##########
@@ -159,7 +159,7 @@ class MathExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
   test("conv") {
     checkEvaluation(Conv(Literal("3"), Literal(10), Literal(2)), "11")
     checkEvaluation(Conv(Literal("-15"), Literal(10), Literal(-16)), "-F")

Review comment:
       In BigInteger
   ```
   public String toString(int radix) {
           if (signum == 0)
               return "0";
           if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
               radix = 10;
   
           // If it's small enough, use smallToString.
           if (mag.length <= SCHOENHAGE_BASE_CONVERSION_THRESHOLD)
              return smallToString(radix);
   
           // Otherwise use recursive toString, which requires positive arguments.
           // The results will be concatenated into this StringBuilder
           StringBuilder sb = new StringBuilder();
           if (signum < 0) {
               toString(this.negate(), sb, radix, 0);
               sb.insert(0, '-');
           }
           else
               toString(this, sb, radix, 0);
   
           return sb.toString();
       }
   ```
   
   `Character.MIN_RADIX`'s value is 2, so any radix less then 2 will be convert to default `10`, should we keep the same behavior?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org