This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new b08f97b43 [hotfix] PredicateConverter should throw 
UnsupportedExpression exception
b08f97b43 is described below

commit b08f97b43ae75f1bda8a127ac0f5204b6e60036f
Author: JingsongLi <[email protected]>
AuthorDate: Sat Mar 18 14:46:25 2023 +0800

    [hotfix] PredicateConverter should throw UnsupportedExpression exception
---
 .../org/apache/paimon/flink/PredicateConverter.java     | 17 +++++++----------
 .../org/apache/paimon/flink/PredicateConverterTest.java | 11 +++++++++--
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git 
a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/PredicateConverter.java
 
b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/PredicateConverter.java
index e6eb48c74..2b72736e8 100644
--- 
a/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/PredicateConverter.java
+++ 
b/paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/PredicateConverter.java
@@ -133,7 +133,7 @@ public class PredicateConverter implements 
ExpressionVisitor<Predicate> {
                     allowQuick = true;
                 } else if (escape != null) {
                     if (escape.length() != 1) {
-                        throw new RuntimeException("Invalid escape character 
'" + escape + "'");
+                        throw new UnsupportedExpression();
                     }
                     char escapeChar = escape.charAt(0);
                     boolean matched = true;
@@ -143,8 +143,7 @@ public class PredicateConverter implements 
ExpressionVisitor<Predicate> {
                         char c = sqlPattern.charAt(i);
                         if (c == escapeChar) {
                             if (i == (sqlPattern.length() - 1)) {
-                                throw new RuntimeException(
-                                        "Invalid escape sequence '" + 
sqlPattern + "', " + i);
+                                throw new UnsupportedExpression();
                             }
                             char nextChar = sqlPattern.charAt(i + 1);
                             if (nextChar == '%') {
@@ -153,8 +152,7 @@ public class PredicateConverter implements 
ExpressionVisitor<Predicate> {
                                 sb.append(nextChar);
                                 i += 1;
                             } else {
-                                throw new RuntimeException(
-                                        "Invalid escape sequence '" + 
sqlPattern + "', " + i);
+                                throw new UnsupportedExpression();
                             }
                         } else if (c == '_') {
                             matched = false;
@@ -276,23 +274,22 @@ public class PredicateConverter implements 
ExpressionVisitor<Predicate> {
 
     @Override
     public Predicate visit(ValueLiteralExpression valueLiteralExpression) {
-        throw new RuntimeException("Literal should be resolved in call 
expression.");
+        throw new UnsupportedExpression();
     }
 
     @Override
     public Predicate visit(FieldReferenceExpression fieldReferenceExpression) {
-        throw new RuntimeException("Field reference should be resolved in call 
expression.");
+        throw new UnsupportedExpression();
     }
 
     @Override
     public Predicate visit(TypeLiteralExpression typeLiteralExpression) {
-        throw new RuntimeException(
-                "Type literal is unsupported: " + 
typeLiteralExpression.asSummaryString());
+        throw new UnsupportedExpression();
     }
 
     @Override
     public Predicate visit(Expression expression) {
-        throw new RuntimeException("Unsupported expression: " + 
expression.asSummaryString());
+        throw new UnsupportedExpression();
     }
 
     /**
diff --git 
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PredicateConverterTest.java
 
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PredicateConverterTest.java
index 398c6156c..ce20ecf01 100644
--- 
a/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PredicateConverterTest.java
+++ 
b/paimon-flink/paimon-flink-common/src/test/java/org/apache/paimon/flink/PredicateConverterTest.java
@@ -76,8 +76,7 @@ public class PredicateConverterTest {
             assertThat(CONVERTER.visit((CallExpression) 
expression)).isEqualTo(expected);
         } else {
             assertThatThrownBy(() -> CONVERTER.visit(expression))
-                    .isInstanceOf(RuntimeException.class)
-                    .hasMessageContaining("Unsupported expression");
+                    
.isInstanceOf(PredicateConverter.UnsupportedExpression.class);
         }
     }
 
@@ -771,6 +770,14 @@ public class PredicateConverterTest {
                 .isInstanceOf(PredicateConverter.UnsupportedExpression.class);
     }
 
+    @Test
+    public void testUnsupportedFieldReferenceExpression() {
+        PredicateConverter converter = new PredicateConverter(RowType.of(new 
VarCharType()));
+        DataType structType = 
DataTypes.ROW(DataTypes.INT()).bridgedTo(Row.class);
+        assertThatThrownBy(() -> field(0, structType).accept(converter))
+                .isInstanceOf(PredicateConverter.UnsupportedExpression.class);
+    }
+
     private static FieldReferenceExpression field(int i, DataType type) {
         return new FieldReferenceExpression("f" + i, type, Integer.MAX_VALUE, 
Integer.MAX_VALUE);
     }

Reply via email to