You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@paimon.apache.org by lz...@apache.org on 2023/03/18 06:40:17 UTC
[incubator-paimon] branch release-0.3 updated: [hotfix] PredicateConverter should throw UnsupportedExpression exception
This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch release-0.3
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git
The following commit(s) were added to refs/heads/release-0.3 by this push:
new 768260143 [hotfix] PredicateConverter should throw UnsupportedExpression exception
768260143 is described below
commit 768260143396032b8d0683a6db288514fa37b0ab
Author: JingsongLi <lz...@aliyun.com>
AuthorDate: Sat Mar 18 14:36:20 2023 +0800
[hotfix] PredicateConverter should throw UnsupportedExpression exception
---
.../table/store/file/predicate/PredicateConverter.java | 17 +++++++----------
.../store/file/predicate/PredicateConverterTest.java | 11 +++++++++--
2 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/flink-table-store-common/src/main/java/org/apache/flink/table/store/file/predicate/PredicateConverter.java b/flink-table-store-common/src/main/java/org/apache/flink/table/store/file/predicate/PredicateConverter.java
index 9cdfcaf6d..4e0dd7cf1 100644
--- a/flink-table-store-common/src/main/java/org/apache/flink/table/store/file/predicate/PredicateConverter.java
+++ b/flink-table-store-common/src/main/java/org/apache/flink/table/store/file/predicate/PredicateConverter.java
@@ -132,7 +132,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;
@@ -142,8 +142,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 == '%') {
@@ -152,8 +151,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;
@@ -271,23 +269,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/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/predicate/PredicateConverterTest.java b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/predicate/PredicateConverterTest.java
index 90b1bd4f7..5cc8a97b1 100644
--- a/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/predicate/PredicateConverterTest.java
+++ b/flink-table-store-core/src/test/java/org/apache/flink/table/store/file/predicate/PredicateConverterTest.java
@@ -70,8 +70,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);
}
}
@@ -741,6 +740,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);
}