Skip to content

[BugFix]Fix unclear error messages when an unsupported regex type is … #57904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.re2j.Pattern;
import com.google.re2j.PatternSyntaxException;
import com.starrocks.analysis.AnalyticExpr;
import com.starrocks.analysis.ArithmeticExpr;
import com.starrocks.analysis.ArraySliceExpr;
Expand Down Expand Up @@ -114,7 +115,6 @@
import java.util.Objects;
import java.util.Set;
import java.util.function.Consumer;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;

import static com.starrocks.sql.analyzer.AnalyticAnalyzer.verifyAnalyticExpression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.starrocks.analysis.CollectionElementExpr;
import com.starrocks.analysis.Expr;
import com.starrocks.analysis.IntLiteral;
import com.starrocks.analysis.LikePredicate;
import com.starrocks.analysis.SlotRef;
import com.starrocks.analysis.StringLiteral;
import com.starrocks.analysis.UserVariableExpr;
Expand Down Expand Up @@ -226,4 +227,16 @@ public void testUserVariableExprAnalyzer() {
UserVariableExpr copy = (UserVariableExpr) userVariableExpr.clone();
Assert.assertEquals(userVariableExpr, copy);
}

@Test
public void testLikePatternSyntaxException() {
StringLiteral e1 = new StringLiteral("a");
e1.setType(Type.VARCHAR);
StringLiteral e2 = new StringLiteral("([A-Za-z0-9]+[\\u4e00-\\u9fa5]{2}[A-Za-z0-9]+)");
e2.setType(Type.VARCHAR);
LikePredicate likePredicate = new LikePredicate(LikePredicate.Operator.REGEXP, e1, e2);
ExpressionAnalyzer.Visitor visitor = new ExpressionAnalyzer.Visitor(new AnalyzeState(), new ConnectContext());
Assert.assertThrows(SemanticException.class, () -> visitor.visitLikePredicate(likePredicate,
new Scope(RelationId.anonymous(), new RelationFields())));
}
}
Loading