flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twalthr <...@git.apache.org>
Subject [GitHub] flink pull request #4127: [FLINK-6892][table]Add L/RPAD supported in SQL
Date Wed, 10 Jan 2018 09:50:06 GMT
Github user twalthr commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4127#discussion_r160629246
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/functions/ScalarFunctions.scala
---
    @@ -104,9 +103,84 @@ object ScalarFunctions {
         }
         if (base <= 1.0) {
           throw new IllegalArgumentException(s"base of 'log(base, x)' must be > 1, but
base = $base")
    -    }
    -    else {
    +    } else {
           Math.log(x) / Math.log(base)
         }
       }
    +
    +  /**
    +    * Returns the string str, left-padded with the string pad to a length of len characters.
    +    * If str is longer than len, the return value is shortened to len characters.
    +    */
    +  def lpad(base: String, len: Integer, pad: String): String = {
    +    if (base == null || len == null || pad == null) {
    --- End diff --
    
    `addSqlFunctionMethod` already checks for null in the arguments so we can use primitive
integer here and remove this checks.


---

Mime
View raw message