You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by bomeng <gi...@git.apache.org> on 2016/04/06 16:07:27 UTC

[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

GitHub user bomeng opened a pull request:

    https://github.com/apache/spark/pull/12206

    [SPARK-14429] [SQL] Improve LIKE pattern in "SHOW TABLES / FUNCTIONS LIKE <pattern>" DDL

    ## What changes were proposed in this pull request?
    
    LIKE <pattern> is commonly used in SHOW TABLES / FUNCTIONS etc DDL. In the pattern, user can use `|` or `*` as wildcards.
    
    1. Currently, we used `replaceAll()` to replace `*` with `.*`, but the replacement was scattered in several places; I have created an utility method and use it in all the places;
    
    2. Consistency with Hive: the pattern is case insensitive in Hive and white spaces will be trimmed, but current pattern matching does not do that. For example, suppose we have tables (t1, t2, t3), `SHOW TABLES LIKE ' T* ' ` will list all the t-tables. Please use Hive to verify it.
    
    I've made some changes to the utility method to make sure we will get the same result as Hive does.
    
    ## How was this patch tested?
    
    A new method was created in StringUtil and test cases were added.
    
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/bomeng/spark SPARK-14429

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/12206.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #12206
    
----
commit b76ccd826a5c7780c73332e059cd31a8daee68a1
Author: bomeng <bm...@us.ibm.com>
Date:   2016-04-06T14:01:09Z

    fix like pattern in show ddl

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12206#issuecomment-206436956
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on the pull request:

    https://github.com/apache/spark/pull/12206#issuecomment-206491670
  
    LGTM, just a few style nits


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on the pull request:

    https://github.com/apache/spark/pull/12206#issuecomment-206493611
  
    I'll fix those myself on merge actually. Merging into master.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12206#discussion_r58752254
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/StringUtils.scala ---
    @@ -52,4 +52,26 @@ object StringUtils {
     
       def isTrueString(s: UTF8String): Boolean = trueStrings.contains(s.toLowerCase)
       def isFalseString(s: UTF8String): Boolean = falseStrings.contains(s.toLowerCase)
    +
    +  /**
    +   * This utility can be used for filtering pattern in the "Like" of "Show Tables / Functions" DDL
    +   * @param names the names list to be filtered
    +   * @param pattern the filter pattern, only '*' and '|' are allowed as wildcards, others will
    +   *                follows regular expression convention, case insensitive match and white spaces
    +   *                on both ends will be ignored
    +   * @return the filtered names list in order
    +   */
    +  def filterPattern(names: Seq[String], pattern: String): Seq[String] = {
    +    val funcNames = scala.collection.mutable.SortedSet.empty[String]
    +    pattern.trim().split("\\|").foreach {
    +      subPattern =>
    +        try {
    +          val regex = ("(?i)" + subPattern.replaceAll("\\*", ".*")).r
    +          funcNames ++= names.filter{name => regex.pattern.matcher(name).matches()}
    --- End diff --
    
    style: `filter { name => ... }`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/12206


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/12206#issuecomment-206436961
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/55114/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by bomeng <gi...@git.apache.org>.
Github user bomeng commented on the pull request:

    https://github.com/apache/spark/pull/12206#issuecomment-206513733
  
    @andrewor14 Cool, thanks. I will pay more attention to the coding style next time.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12206#discussion_r58752400
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/StringUtils.scala ---
    @@ -52,4 +52,26 @@ object StringUtils {
     
       def isTrueString(s: UTF8String): Boolean = trueStrings.contains(s.toLowerCase)
       def isFalseString(s: UTF8String): Boolean = falseStrings.contains(s.toLowerCase)
    +
    +  /**
    +   * This utility can be used for filtering pattern in the "Like" of "Show Tables / Functions" DDL
    +   * @param names the names list to be filtered
    +   * @param pattern the filter pattern, only '*' and '|' are allowed as wildcards, others will
    +   *                follows regular expression convention, case insensitive match and white spaces
    +   *                on both ends will be ignored
    +   * @return the filtered names list in order
    +   */
    +  def filterPattern(names: Seq[String], pattern: String): Seq[String] = {
    +    val funcNames = scala.collection.mutable.SortedSet.empty[String]
    +    pattern.trim().split("\\|").foreach {
    --- End diff --
    
    style:
    ```
    ....foreach { subPattern =>
      try {
      } ...
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12206#issuecomment-206390653
  
    **[Test build #55114 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55114/consoleFull)** for PR 12206 at commit [`b76ccd8`](https://github.com/apache/spark/commit/b76ccd826a5c7780c73332e059cd31a8daee68a1).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-14429] [SQL] Improve LIKE pattern in "S...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/12206#issuecomment-206436551
  
    **[Test build #55114 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/55114/consoleFull)** for PR 12206 at commit [`b76ccd8`](https://github.com/apache/spark/commit/b76ccd826a5c7780c73332e059cd31a8daee68a1).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org