Skip to content
Merged
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 @@ -35,7 +35,7 @@ public class PatternMatcher {
private boolean caseSensitive;

private static final Set<Character> FORBIDDEN_CHARS = Sets.newHashSet('<', '(', '[', '{', '^', '=',
'$', '!', '|', ']', '}', ')',
'!', '|', ']', '}', ')',
'?', '*', '+', '>', '@');

public PatternMatcher(Pattern pattern) {
Expand Down Expand Up @@ -121,6 +121,9 @@ private static String convertMysqlPattern(String mysqlPattern) throws PatternMat
case '.':
sb.append("\\.");
break;
case '$':
Comment thread
Gabriel39 marked this conversation as resolved.
sb.append("\\$");
break;
case '_':
sb.append(".");
break;
Expand Down Expand Up @@ -166,9 +169,9 @@ private static String convertMysqlPattern(String mysqlPattern) throws PatternMat
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public void testNormal() {
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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
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.TLoadTxnCommitRequest;
Expand Down Expand Up @@ -145,6 +147,19 @@ private static void setPrivateField(Object target, String fieldName, Object valu
field.set(target, value);
}

@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 {
Expand Down
Loading