Hisoka-X commented on code in PR #9653:
URL: https://github.com/apache/seatunnel/pull/9653#discussion_r2250306595


##########
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:
   we should thrown exception when all patterns not matched.



##########
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("([^%]+)%");

Review Comment:
   we should make sure % is string end.



##########
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("%([^%]+)");

Review Comment:
   we should make sure the % is string start.



##########
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("%([^%]+)%");

Review Comment:
   ditto.



-- 
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]

Reply via email to