You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "dylanhz (via GitHub)" <gi...@apache.org> on 2024/07/29 06:01:20 UTC
[PR] [FLINK-35910][Table SQL / API] Add BTRIM function [flink]
dylanhz opened a new pull request, #25127:
URL: https://github.com/apache/flink/pull/25127
## What is the purpose of the change
Add CONV function.
Examples:
```SQL
> SELECT BTRIM(' test ');
test
> SELECT BTRIM('test', 't');
es
```
## Brief change log
[FLINK-35910](https://issues.apache.org/jira/browse/FLINK-35910)
## Verifying this change
`StringFunctionsITCase#bTrimTestCases`
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (no)
- The serializers: (no)
- The runtime per-record code paths (performance sensitive): (no)
- Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn, ZooKeeper: (no)
- The S3 file system connector: (no)
## Documentation
- Does this pull request introduce a new feature? (yes)
- If yes, how is the feature documented? (docs)
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][Table SQL / API] Add BTRIM function [flink]
Posted by "lsyldliu (via GitHub)" <gi...@apache.org>.
lsyldliu commented on code in PR #25127:
URL: https://github.com/apache/flink/pull/25127#discussion_r1696908937
##########
docs/data/sql_functions.yml:
##########
@@ -274,6 +274,12 @@ string:
- sql: RTRIM(string)
table: STRING.rtrim()
description: Returns a string that removes the right whitespaces from STRING. E.g., 'This is a test String. '.rtrim() returns "This is a test String.".
+ - sql: BTRIM(str[, trimStr])
+ table: str.btrim([trimStr])
+ description: |
+ Removes any leading and trailing characters within trimStr from str. trimStr is set to a space character by default.
+ str <CHAR | VARCHAR>[, trimStr <CHAR | VARCHAR>]
Review Comment:
```suggestion
str <CHAR | VARCHAR>
trimStr <CHAR | VARCHAR>
```
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/StringFunctionsITCase.java:
##########
@@ -46,4 +51,70 @@ Stream<TestSetSpec> getTestSetSpecs() {
"ABC",
DataTypes.STRING().nullable()));
}
+
+ private Stream<TestSetSpec> bTrimTestCases() {
+ return Stream.of(
+ TestSetSpec.forFunction(BuiltInFunctionDefinitions.BTRIM)
+ .onFieldsWithData(null, " \uD83D\uDE00www.apache.org \f ")
+ .andDataTypes(DataTypes.STRING(), DataTypes.STRING())
+ // null input
+ .testResult($("f0").btrim(), "BTRIM(f0)", null, DataTypes.STRING())
+ .testResult(
+ $("f0").btrim($("f1")), "BTRIM(f0, f1)", null, DataTypes.STRING())
+ .testResult(
+ $("f1").btrim($("f0")), "BTRIM(f1, f0)", null, DataTypes.STRING())
+ // special chars
+ .testResult(
+ $("f1").btrim(" \f\uD83D\uDE00"),
+ "BTRIM(f1, ' \f\uD83D\uDE00')",
+ "www.apache.org",
+ DataTypes.STRING())
+ .testResult(
+ $("f1").btrim("\uD83D\uDE00 "),
+ "BTRIM(f1, '\uD83D\uDE00 ')",
+ "www.apache.org \f",
+ DataTypes.STRING())
+ // return type
+ .testResult(
+ lit(" www.apache.org ").btrim(),
+ "BTRIM(' www.apache.org ')",
+ "www.apache.org",
+ DataTypes.STRING().notNull())
+ // normal cases
+ .testResult(
+ $("f1").btrim(),
+ "BTRIM(f1)",
+ "\uD83D\uDE00www.apache.org \f",
+ DataTypes.STRING())
+ .testResult(
+ $("f1").btrim("\f"),
+ "BTRIM(f1, '\f')",
+ " \uD83D\uDE00www.apache.org \f ",
Review Comment:
Can you also a normal test case: btrim(f1, 'a');
##########
docs/data/sql_functions_zh.yml:
##########
@@ -340,6 +340,12 @@ string:
description: |
返回从 STRING 中删除右边空格的字符串。
例如 `'This is a test String. '.rtrim()` 返回 `'This is a test String.'`。
+ - sql: BTRIM(str[, trimStr])
+ table: str.btrim([trimStr])
+ description: |
+ 从 str 的前缀和后缀字符中裁去 trimStr 中的字符。trimStr 默认设置为空格。
Review Comment:
前缀 -> 左边;后缀 -> 右边。
裁剪 -> 删除
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][table] Add the built-in function BTRIM [flink]
Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2270835060
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][table] Add the built-in function BTRIM [flink]
Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2270203780
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][table] Add BTRIM function [flink]
Posted by "lsyldliu (via GitHub)" <gi...@apache.org>.
lsyldliu commented on code in PR #25127:
URL: https://github.com/apache/flink/pull/25127#discussion_r1703130983
##########
flink-python/pyflink/table/expression.py:
##########
@@ -1315,6 +1315,16 @@ def rtrim(self) -> 'Expression[str]':
"""
return _unary_op("rtrim")(self)
+ def btrim(self, trim_str=None) -> 'Expression':
+ """
+ Removes any leading and trailing characters within trim_str from str.
+ trim_str is set to a space character by default.
Review Comment:
```suggestion
trim_str is set to whitespace by default.
```
##########
docs/data/sql_functions.yml:
##########
@@ -274,6 +274,12 @@ string:
- sql: RTRIM(string)
table: STRING.rtrim()
description: Returns a string that removes the right whitespaces from STRING. E.g., 'This is a test String. '.rtrim() returns "This is a test String.".
+ - sql: BTRIM(str[, trimStr])
+ table: str.btrim([trimStr])
+ description: |
+ Removes any leading and trailing characters within trimStr from str. trimStr is set to a space character by default.
Review Comment:
```suggestion
Removes any leading and trailing characters within trimStr from str. trimStr is set to whitespace by default.
```
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][Table SQL / API] Add BTRIM function [flink]
Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2255392100
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][table] Add the built-in function BTRIM [flink]
Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2270429171
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][Table SQL / API] Add BTRIM function [flink]
Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2255285626
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][table] Add BTRIM function [flink]
Posted by "lsyldliu (via GitHub)" <gi...@apache.org>.
lsyldliu commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2267459967
@dylanhz Can you help resolve the conflict and rebase the master branch?
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][table] Add the built-in function BTRIM [flink]
Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2268840820
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][table] Add the built-in function BTRIM [flink]
Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2268322441
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][table] Add the built-in function BTRIM [flink]
Posted by "dylanhz (via GitHub)" <gi...@apache.org>.
dylanhz commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2270462361
@flinkbot run azure
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][table] Add the built-in function BTRIM [flink]
Posted by "lsyldliu (via GitHub)" <gi...@apache.org>.
lsyldliu merged PR #25127:
URL: https://github.com/apache/flink/pull/25127
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-35910][Table SQL / API] Add BTRIM function [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #25127:
URL: https://github.com/apache/flink/pull/25127#issuecomment-2255016744
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "28a6f290b0a46e7c73d27e07f2bba8a146ee2bc6",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "28a6f290b0a46e7c73d27e07f2bba8a146ee2bc6",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 28a6f290b0a46e7c73d27e07f2bba8a146ee2bc6 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
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.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org