[
https://issues.apache.org/jira/browse/FLINK-3498?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15173865#comment-15173865
]
ASF GitHub Bot commented on FLINK-3498:
---------------------------------------
Github user twalthr commented on a diff in the pull request:
https://github.com/apache/flink/pull/1747#discussion_r54578368
--- 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 --
Yes, makes sense. I updated the PR.
> Implement TRIM, SUBSTRING as reference design for Table API
> -----------------------------------------------------------
>
> Key: FLINK-3498
> URL: https://issues.apache.org/jira/browse/FLINK-3498
> Project: Flink
> Issue Type: Sub-task
> Components: Table API
> Reporter: Timo Walther
> Assignee: Timo Walther
>
> As described in FLINK-3497 TRIM and SUBSTRING are the first scalar functions
> implemented in Calcite and used in Table API.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)