flink icon indicating copy to clipboard operation
flink copied to clipboard

[FLINK-36025][table] Add the built-in function TO_NUMBER

Open dylanhz opened this issue 1 year ago • 1 comments

What is the purpose of the change

Add the built-in function TO_NUMBER. Examples:

-- The format expects:
--  * an optional sign at the beginning,
--  * followed by a dollar sign,
--  * followed by a number between 3 and 6 digits long,
--  * thousands separators,
--  * up to two dight beyond the decimal point.
> SELECT TO_NUMBER('-$12,345.67', 'S$999,099.99');
 -12345.67

-- Plus is optional, and so are fractional digits.
> SELECT TO_NUMBER('$345', 'S$999,099.99');
 345.00

-- The format requires at least three digits.
> SELECT TO_NUMBER('$45', 'S$999,099.99');
 NULL

-- The format requires at least three digits
> SELECT TO_NUMBER('$045', 'S$999,099.99');
 45.00

-- Using brackets to denote negative values
> SELECT TO_NUMBER('<1234>', '999999PR');
 -1234

Brief change log

  • FLINK-36025
  • Add ToNumberTypeStrategy
  • Add NumberParser
  • Fix doc issue of function PRINTF

Verifying this change

  • StringFunctionsITCase#toNumberTestCases
  • TypeStrategiesTest#testData
  • NumberParserTest

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): (yes)
  • 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)

dylanhz avatar Aug 19 '24 09:08 dylanhz

CI report:

  • d8298338af849ca2e744947aa6ce9b1c687b36d9 Azure: SUCCESS
Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run azure re-run the last Azure build

flinkbot avatar Aug 19 '24 09:08 flinkbot

This PR is being marked as stale since it has not had any activity in the last 90 days. If you would like to keep this PR alive, please leave a comment asking for a review. If the PR has merge conflicts, update it with the latest from the base branch.

If you are having difficulty finding a reviewer, please reach out to the community, contact details can be found here: https://flink.apache.org/what-is-flink/community/

If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed.

github-actions[bot] avatar Apr 07 '25 06:04 github-actions[bot]

This PR has been closed since it has not had any activity in 120 days. If you feel like this was a mistake, or you would like to continue working on it, please feel free to re-open the PR and ask for a review.

github-actions[bot] avatar May 08 '25 06:05 github-actions[bot]