Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21542#discussion_r195884790
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ---
    @@ -1507,7 +1507,8 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
             case "TIMESTAMP" =>
               Literal(Timestamp.valueOf(value))
             case "X" =>
    -          val padding = if (value.length % 2 == 1) "0" else ""
    +          // avoid false positive of IM_BAD_CHECK_FOR_ODD by SpotBugs
    --- End diff --
    
    
[It](http://spotbugs.readthedocs.io/en/latest/bugDescriptions.html#im-check-for-oddness-that-won-t-work-for-negative-numbers-im-bad-check-for-odd)
 means `x % 2 == ` does not work correctly if x is negative.
    
    In this case, we know `value.length` is always non-negative . The current 
SpotBugs cannot detect this pre-condition. I cannot find to disable only this 
check in `findPuzzles`, too.
    
    Therefore, this is a workaround to avoid the false positive violation.


---

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

Reply via email to