flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fhueske <...@git.apache.org>
Subject [GitHub] flink pull request: [FLINK-3498] Implement TRIM, SUBSTRING as refe...
Date Tue, 01 Mar 2016 13:43:41 GMT
Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1747#discussion_r54567411
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/api/scala/table/expressionDsl.scala
---
    @@ -63,17 +63,77 @@ trait ImplicitExpressionOperations {
       def count = Count(expr)
       def avg = Avg(expr)
     
    +  def cast(toType: TypeInformation[_]) = Cast(expr, toType)
    +
    +  def as(name: Symbol) = Naming(expr, name.name)
    +
    +  // scalar functions
    +
    +  /**
    +    * Creates a substring of the given string between the given indices.
    +    *
    +    * @param beginIndex first character of the substring (starting at 1, inclusive)
    +    * @param endIndex last character of the substring (starting at 1, inclusive)
    +    * @return substring
    +    */
       def substring(beginIndex: Expression, endIndex: Expression) = {
    -    Substring(expr, beginIndex, Some(endIndex))
    +    Call(BuiltInFunctionNames.SUBSTRING, expr, beginIndex, endIndex)
       }
     
    +  /**
    +    * Creates a substring of the given string beginning at the given index to the end.
    +    *
    +    * @param beginIndex first character of the substring (starting at 1, inclusive)
    +    * @return substring
    +    */
       def substring(beginIndex: Expression) = {
    -    Substring(expr, beginIndex)
    +    Call(BuiltInFunctionNames.SUBSTRING, expr, beginIndex)
       }
     
    -  def cast(toType: TypeInformation[_]) = Cast(expr, toType)
    +  /**
    +    * Removes leading and trailing whitespaces from the given string.
    +    *
    +    * @return trimmed string
    +    */
    +  def trim() = {
    +    Call(
    +      BuiltInFunctionNames.TRIM,
    +      BuiltInFunctionConstants.TRIM_BOTH,
    +      BuiltInFunctionConstants.TRIM_DEFAULT_CHAR,
    +      expr)
    +  }
     
    -  def as(name: Symbol) = Naming(expr, name.name)
    +  /**
    +    * Removes leading and/or trailing characters from the given string.
    +    *
    +    * @param removeLeading if true, remove leading characters
    +    * @param removeTrailing if true, remove trailing characters
    +    * @param character String containing the character
    +    * @return trimmed string
    +    */
    +  def trim(removeLeading: Boolean, removeTrailing: Boolean, character: Expression) =
{
    --- End diff --
    
    Can we remove the `trim()` method if we add the default values to the parameters in this
function?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message