This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new bbc3f18349b [fix]result is empty when execute 'show resources where 
name like' (#50408)
bbc3f18349b is described below

commit bbc3f18349b3eb585986bd1eaa8e47d651164c47
Author: lsy3993 <[email protected]>
AuthorDate: Mon Apr 28 09:42:35 2025 +0800

    [fix]result is empty when execute 'show resources where name like' (#50408)
    
    Related PR: #50230
---
 .../nereids/trees/plans/commands/ShowResourcesCommand.java | 14 +++++++++++++-
 .../nereids_p0/show/test_nereids_show_resources.groovy     |  7 +++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowResourcesCommand.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowResourcesCommand.java
index 143ea3954d6..143e0f8ba2d 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowResourcesCommand.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowResourcesCommand.java
@@ -60,7 +60,7 @@ import java.util.Set;
  */
 public class ShowResourcesCommand extends ShowCommand {
     private final Expression wildWhere;
-    private final String likePattern;
+    private String likePattern;
     private final List<OrderKey> orderKeys;
     private final long limit;
     private final long offset;
@@ -108,10 +108,22 @@ public class ShowResourcesCommand extends ShowCommand {
         // then process the order by
         orderByPairs = processOrderBy();
 
+        // when execute "show resources like '%xxx%'", the likePattern is 
'%xxx%',
+        // when execute "shore resources where name like '%xxx%'", the 
likePattern is null,
+        // we use likePattern to handle the two statements.
         PatternMatcher matcher = null;
         if (likePattern != null) {
             matcher = PatternMatcherWrapper.createMysqlPattern(likePattern,
                     CaseSensibility.RESOURCE.getCaseSensibility());
+        } else {
+            if (wildWhere instanceof Like) {
+                if (wildWhere.child(1) instanceof StringLikeLiteral) {
+                    likePattern = ((StringLikeLiteral) 
wildWhere.child(1)).getStringValue();
+                    matcher = 
PatternMatcherWrapper.createMysqlPattern(likePattern,
+                            CaseSensibility.RESOURCE.getCaseSensibility());
+                    nameValue = null;
+                }
+            }
         }
 
         // sort the result
diff --git 
a/regression-test/suites/nereids_p0/show/test_nereids_show_resources.groovy 
b/regression-test/suites/nereids_p0/show/test_nereids_show_resources.groovy
index cb7f1c79d0e..49a1a693a7b 100644
--- a/regression-test/suites/nereids_p0/show/test_nereids_show_resources.groovy
+++ b/regression-test/suites/nereids_p0/show/test_nereids_show_resources.groovy
@@ -77,6 +77,13 @@ suite("test_nereids_show_resources") {
     assertEquals("jdbc", res2.get(0).get(1))
     assertEquals("jdbc", res2.get(size2 - 1).get(1))
 
+    def res3 = sql """SHOW RESOURCES WHERE NAME like 
'test_resource_for_show_resources%'"""
+    def size3 = res3.size()
+    assertEquals("test_resource_for_show_resources", res3.get(0).get(0))
+    assertEquals("test_resource_for_show_resources", res3.get(size3 - 
1).get(0))
+    assertEquals("jdbc", res3.get(0).get(1))
+    assertEquals("jdbc", res3.get(size3 - 1).get(1))
+
     def res4 = sql """SHOW RESOURCES like 
'test_resource_for_show_resources%'"""
     def size4 = res4.size()
     assertEquals("test_resource_for_show_resources", res4.get(0).get(0))


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to