hawk9821 commented on code in PR #9653:
URL: https://github.com/apache/seatunnel/pull/9653#discussion_r2256440199
##########
seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/source/converter/SqlToPaimonPredicateConverter.java:
##########
@@ -253,14 +253,23 @@ private static Predicate parseExpressionToPredicate(
convertValueByPaimonDataType(rowType,
column.getColumnName(), rightPredicate);
Pattern BEGIN_PATTERN = Pattern.compile("([^%]+)%");
- Matcher matcher = BEGIN_PATTERN.matcher(rightVal.toString());
- if (matcher.matches()) {
- return builder.startsWith(columnIndex,
BinaryString.fromString(matcher.group(1)));
- } else {
- throw new IllegalArgumentException(
- "Unsupported expression type: "
- + expression.getClass().getSimpleName()
- + ", only support like pattern matching with
prefix");
+ Matcher beginMatcher = BEGIN_PATTERN.matcher(rightVal.toString());
+ if (beginMatcher.matches()) {
+ return builder.startsWith(
+ columnIndex,
BinaryString.fromString(beginMatcher.group(1)));
+ }
+
+ Pattern END_PATTERN = Pattern.compile("%([^%]+)");
+ Matcher endMatcher = END_PATTERN.matcher(rightVal.toString());
+ if (endMatcher.matches()) {
+ return builder.endsWith(columnIndex,
BinaryString.fromString(endMatcher.group(1)));
+ }
+
+ Pattern CONTAINS_PATTERN = Pattern.compile("%([^%]+)%");
+ Matcher containsMatcher =
CONTAINS_PATTERN.matcher(rightVal.toString());
+ if (containsMatcher.matches()) {
+ return builder.contains(
+ columnIndex,
BinaryString.fromString(containsMatcher.group(1)));
}
Review Comment:
when all of them don't match, an exception should be thrown.
[SqlToPaimonPredicateConverter.java#L274](https://github.com/apache/seatunnel/blob/610e7da09ec0adef02b36e1ec6f019f8a1b9945f/seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/source/converter/SqlToPaimonPredicateConverter.java#L274)
--
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]