JingsongLi commented on code in PR #1140:
URL: https://github.com/apache/incubator-paimon/pull/1140#discussion_r1192002543
##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/action/cdc/mysql/Expression.java:
##########
@@ -61,21 +63,55 @@ static Expression year(String fieldReference) {
return new YearComputer(fieldReference);
}
- /** Compute year from a time input. */
- final class YearComputer implements Expression {
-
- private static final long serialVersionUID = 1L;
+ static Expression substring(String fieldReference, String... literals) {
+ checkArgument(
+ literals.length == 2,
+ "'substring' expression needs begin index and end index
arguments.");
+ int beginInclusive, endExclusive;
+ try {
+ beginInclusive = Integer.parseInt(literals[0]);
+ endExclusive = Integer.parseInt(literals[1]);
+ } catch (NumberFormatException e) {
+ throw new RuntimeException(
+ String.format(
+ "begin index (%s) or end index (%s) is not an
integer.",
+ literals[0], literals[1]),
+ e);
+ }
+ checkArgument(
+ beginInclusive >= 0,
+ "begin index argument (%s) of 'substring' must be >= 0.",
+ beginInclusive);
+ checkArgument(
+ endExclusive > beginInclusive,
+ "end index (%s) must be larger than begin index (%s).",
+ endExclusive,
+ beginInclusive);
+ return new Substring(fieldReference, beginInclusive, endExclusive);
+ }
+ /** Expression that only reference single field. */
+ abstract class SingleFieldReferenceExpression implements Expression {
Review Comment:
We don't need `SingleFieldReferenceExpression` this one.
--
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]