Zkplo opened a new pull request, #11086:
URL: https://github.com/apache/inlong/pull/11086
<!-- Prepare a Pull Request
Change the title of pull request refer to the following example:
[INLONG-XYZ][Component] Title of the pull request
-->
<!-- Specify the issue this pull request going to fix.
The following *XYZ* should be replaced by the actual [GitHub
Issue](https://github.com/apache/inlong/issues) number)-->
Fixes #11081
### Motivation
Based on
[Mysql](https://dev.mysql.com/doc/refman/8.4/en/expressions.html#temporal-intervals):
1. Added IntervalParser class
```
IntervalParser <-> INTERVAL expr unit ->
Pair(factor,Map(ChronoField,Count)):
`factor`:
1) `expr` can accept strings starting with '-', representing the meaning
of subtraction.
So the positive or negative sign of `factor` indicates whether `expr`
starts with a '-' or not.
2) For units like WEEK and QUARTER, it is not easy to parse,
so WEEK -> ( unit=DAY, adb(factor)=7 ); QUARTER -> ( unit=MONTH,
adb(factor)=3 ).
`Map(ChronoField,Count)`:
IntervalParser will automatically match the corresponding
DateTimeFormatter based on the input `expr`,
Based on DateTimeFormatter, IntervalParser will parse the incoming units
and store them in a Map.
In addition,acceptable expression parsing and specifying parameters in two
ways:
1) interval rowName year -> expression
3) interval 2 year -> fixed parameter
```
2. Modified AdditionParser and SubtractionParser to have the ability of time
calculation.
3. Also, add the corresponding unit test classe: TestAdditionParser,
TestSubtractionParser
### Modifications
<!--Describe the modifications you've done.-->
### Verifying this change
*(Please pick either of the following options)*
- [ ] This change is a trivial rework/code cleanup without any test coverage.
- [x] This change is already covered by existing tests, such as:
*(please describe tests)*
- [ ] This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end deployment with large payloads
(10MB)*
- *Extended integration test for recovery after broker failure*
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]