Hello, is there a guide to using regular expressio...
# troubleshooting
a
Hello, is there a guide to using regular expressions for SIMILAR TO function in Flink SQL (Table API)? Regular expressions that work on regex101.com do not work with SIMILAR TO in Flink SQL. I want to use
[a-zA-Z0-9~\-_.]+
as my regular expression and my SQL query has the same. It throws the following error
Copy code
Invalid regular expression '[A-Za-z0-9~\-_.]+'
	at org.apache.flink.table.functions.SqlLikeUtils.invalidRegularExpression(SqlLikeUtils.java:178)
	at org.apache.flink.table.functions.SqlLikeUtils.sqlSimilarRewriteCharEnumeration(SqlLikeUtils.java:221)
	at org.apache.flink.table.functions.SqlLikeUtils.sqlToRegexSimilar(SqlLikeUtils.java:285)
	at org.apache.flink.table.functions.SqlLikeUtils.sqlToRegexSimilar(SqlLikeUtils.java:240)
	at org.apache.flink.table.functions.SqlLikeUtils.similar(SqlLikeUtils.java:80)
However,
[A-Za-z0-9~\-.]+
works. The problem is with
_
and it happens on https://github.com/apache/flink/blob/56c81995d3b34ed9066b6771755407b93438f5ab/flin[…]rc/main/java/org/apache/flink/table/functions/SqlLikeUtils.java If the regex contains one of the special characters defined in _SQL_SIMILAR_SPECIALS_, it throws an invalidRegularExpression exception.
s
Maybe running with an escapeChar might help
Copy code
string1 SIMILAR TO string2 [ ESCAPE char ]
just suggesting according to the docs, never really tried before πŸ˜