This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.0 by this push:
new a1295fe2473 branch-4.0: [fix](fe) Support dollar sign in mysql pattern
(#64259)
a1295fe2473 is described below
commit a1295fe2473898faba5d290f0601abf1b1c0f4dc
Author: Gabriel <[email protected]>
AuthorDate: Fri Jun 26 10:13:44 2026 +0800
branch-4.0: [fix](fe) Support dollar sign in mysql pattern (#64259)
### What problem does this PR solve?
#63972
---
.../main/java/org/apache/doris/common/PatternMatcher.java | 11 +++++++----
.../java/org/apache/doris/common/PatternMatcherTest.java | 4 ++++
.../org/apache/doris/service/FrontendServiceImplTest.java | 15 +++++++++++++++
3 files changed, 26 insertions(+), 4 deletions(-)
diff --git
a/fe/fe-common/src/main/java/org/apache/doris/common/PatternMatcher.java
b/fe/fe-common/src/main/java/org/apache/doris/common/PatternMatcher.java
index 9f098134023..fddc6caa055 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/PatternMatcher.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/PatternMatcher.java
@@ -35,7 +35,7 @@ public class PatternMatcher {
private boolean caseSensitive;
private static final Set<Character> FORBIDDEN_CHARS = Sets.newHashSet('<',
'(', '[', '{', '^', '=',
- '$',
'!', '|', ']', '}', ')',
+ '!',
'|', ']', '}', ')',
'?',
'*', '+', '>', '@');
public PatternMatcher(Pattern pattern) {
@@ -121,6 +121,9 @@ public class PatternMatcher {
case '.':
sb.append("\\.");
break;
+ case '$':
+ sb.append("\\$");
+ break;
case '_':
sb.append(".");
break;
@@ -166,9 +169,9 @@ public class PatternMatcher {
break;
}
// look ahead
- if (newMysqlPattern.charAt(i + 1) == '.') {
- // leave '\.' as it is.
- sb.append('\\').append('.');
+ if (newMysqlPattern.charAt(i + 1) == '.' ||
newMysqlPattern.charAt(i + 1) == '$') {
+ // leave '\.' and '\$' as it is.
+ sb.append('\\').append(newMysqlPattern.charAt(i + 1));
i++;
break;
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/common/PatternMatcherTest.java
b/fe/fe-core/src/test/java/org/apache/doris/common/PatternMatcherTest.java
index c7eebf224ec..98c3bcae36f 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/common/PatternMatcherTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/common/PatternMatcherTest.java
@@ -98,6 +98,10 @@ public class PatternMatcherTest {
Assert.assertFalse(matcher.match("my-abc-hostabc"));
Assert.assertFalse(matcher.match("abcmy-abc-host"));
Assert.assertTrue(matcher.match("my-%-host"));
+
+ matcher =
PatternMatcher.createMysqlPattern("test_dropped_partition_field$partitions",
false);
+
Assert.assertTrue(matcher.match("test_dropped_partition_field$partitions"));
+
Assert.assertFalse(matcher.match("test_dropped_partition_fieldapartitions"));
} catch (Exception e) {
Assert.fail(e.getMessage());
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplTest.java
b/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplTest.java
index c748266ecf8..8e6a27681a1 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/service/FrontendServiceImplTest.java
@@ -25,6 +25,7 @@ import org.apache.doris.cloud.CacheHotspotManager;
import org.apache.doris.cloud.catalog.CloudEnv;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeConstants;
+import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.nereids.parser.NereidsParser;
import org.apache.doris.nereids.trees.plans.commands.CreateDatabaseCommand;
import org.apache.doris.nereids.trees.plans.commands.CreateTableCommand;
@@ -39,6 +40,8 @@ import org.apache.doris.thrift.TFetchSchemaTableDataRequest;
import org.apache.doris.thrift.TFetchSchemaTableDataResult;
import org.apache.doris.thrift.TGetDbsParams;
import org.apache.doris.thrift.TGetDbsResult;
+import org.apache.doris.thrift.TGetTablesParams;
+import org.apache.doris.thrift.TGetTablesResult;
import org.apache.doris.thrift.TGetTabletReplicaInfosRequest;
import org.apache.doris.thrift.TGetTabletReplicaInfosResult;
import org.apache.doris.thrift.TMetadataTableRequestParams;
@@ -109,6 +112,18 @@ public class FrontendServiceImplTest {
}
}
+ @Test
+ public void testGetTableNamesWithSysTablePattern() throws Exception {
+ FrontendServiceImpl impl = new FrontendServiceImpl(exeEnv);
+ TGetTablesParams params = new TGetTablesParams();
+ params.setCatalog(InternalCatalog.INTERNAL_CATALOG_NAME);
+ params.setDb("test");
+ params.setPattern("test_dropped_partition_field$partitions");
+
params.setCurrentUserIdent(connectContext.getCurrentUserIdentity().toThrift());
+
+ TGetTablesResult result = impl.getTableNames(params);
+ Assert.assertTrue(result.getTables().isEmpty());
+ }
@Test
public void testCreatePartitionRange() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]