You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by viirya <gi...@git.apache.org> on 2015/04/01 13:17:06 UTC

[GitHub] spark pull request: [SPARK-6647][SQL] Make trait StringComparison ...

GitHub user viirya opened a pull request:

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

    [SPARK-6647][SQL] Make trait StringComparison as BinaryPredicate and throw error when Predicate can't translate to data source Filter

    Now trait `StringComparison` is a `BinaryExpression`. In fact, it should be a `BinaryPredicate`.
    
    By making `StringComparison` as `BinaryPredicate`, we can throw error when a `expressions.Predicate` can't translate to a data source `Filter` in function `selectFilters`.
    
    Without this modification, because we will wrap a `Filter` outside the scanned results in `pruneFilterProjectRaw`, we can't detect about something is wrong in translating predicates to filters in `selectFilters`.
    
    The unit test of #5285 demonstrates such problem. In that pr, even `expressions.Contains` is not properly translated to `sources.StringContains`, the filtering is still performed by the `Filter` and so the test passes.
    
    Of course, by doing this modification, all `expressions.Predicate` classes need to have its data source `Filter` correspondingly.

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

    $ git pull https://github.com/viirya/spark-1 translate_predicate

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

    https://github.com/apache/spark/pull/5309.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 #5309
    
----
commit caf2347251fbb8df4eedc9e7cf49a59eb52ff8d5
Author: Liang-Chi Hsieh <vi...@gmail.com>
Date:   2015-04-01T10:59:05Z

    Make trait StringComparison as BinaryPredicate and throw error when Predicate can't translate to data source Filter.

----


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#discussion_r27704980
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/sources/FilteredScanSuite.scala ---
    @@ -182,15 +185,15 @@ class FilteredScanSuite extends DataSourceTest {
     
       sqlTest(
         "SELECT a, b, c FROM oneToTenFiltered WHERE c like 'c%'",
    -    Seq(Row(3, 3 * 2, "c" * 10)))
    +    Seq(Row(3, 3 * 2, "c" * 5 + "C" * 5)))
     
       sqlTest(
    -    "SELECT a, b, c FROM oneToTenFiltered WHERE c like 'd%'",
    -    Seq(Row(4, 4 * 2, "d" * 10)))
    +    "SELECT a, b, c FROM oneToTenFiltered WHERE c like '%D'",
    +    Seq(Row(4, 4 * 2, "d" * 5 + "D" * 5)))
     
       sqlTest(
    -    "SELECT a, b, c FROM oneToTenFiltered WHERE c like '%e%'",
    -    Seq(Row(5, 5 * 2, "e" * 10)))
    +    "SELECT a, b, c FROM oneToTenFiltered WHERE c like '%eE%'",
    +    Seq(Row(5, 5 * 2, "e" * 5 + "E" * 5)))
     
       testPushDown("SELECT * FROM oneToTenFiltered WHERE A = 1", 1)
    --- End diff --
    
    I think we should also add some more `testPushDown` tests for all the string operations as this would have caught the original issue.


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-88499570
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/29543/
    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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#discussion_r27704826
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/stringOperations.scala ---
    @@ -156,9 +156,9 @@ case class Lower(child: Expression) extends UnaryExpression with CaseConversionE
     
     /** A base trait for functions that compare two strings, returning a boolean. */
     trait StringComparison {
    -  self: BinaryExpression =>
    +  self: BinaryPredicate =>
     
    -  type EvaluatedType = Any
    +  override type EvaluatedType = Any
     
       override def nullable: Boolean = left.nullable || right.nullable
       override def dataType: DataType = BooleanType
    --- End diff --
    
    I think this `dataType` is technically redundant now.


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#discussion_r27704776
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/sources/DataSourceStrategy.scala ---
    @@ -176,6 +176,9 @@ private[sql] object DataSourceStrategy extends Strategy {
           case expressions.Contains(a: Attribute, Literal(v: String, StringType)) =>
             Some(sources.StringContains(a.name, v))
     
    +      case p: expressions.Predicate =>
    --- End diff --
    
    I think I agree.  It is reasonable to have predicates that can't be pushed down for various reasons.  Another issue is this check could often be a runtime error instead of some static compile time check.


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-89341468
  
      [Test build #29678 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/29678/consoleFull) for   PR 5309 at commit [`b176385`](https://github.com/apache/spark/commit/b1763852525a711d4cb6f0f9cdb0910b99a77a09).


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-88444436
  
      [Test build #29540 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/29540/consoleFull) for   PR 5309 at commit [`caf2347`](https://github.com/apache/spark/commit/caf2347251fbb8df4eedc9e7cf49a59eb52ff8d5).


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-88466458
  
      [Test build #29540 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/29540/consoleFull) for   PR 5309 at commit [`caf2347`](https://github.com/apache/spark/commit/caf2347251fbb8df4eedc9e7cf49a59eb52ff8d5).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `class UDFRegistration(object):`
    
     * This patch does not change any dependencies.


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-88466705
  
      [Test build #29543 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/29543/consoleFull) for   PR 5309 at commit [`275a493`](https://github.com/apache/spark/commit/275a4936a9cbce478f3cf62e8cad916df752fb0e).


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-89371981
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/29678/
    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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-89069622
  
    I don't feel too strongly about `BinaryPredicate`, but it seems reasonable to me.  Thanks for adding these tests!


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-89335999
  
    @chenghao-intel as the comment of `StringComparison` is:
    > A base trait for functions that compare two strings, returning a boolean
    
    Because it compares two strings and returns a boolean value, it is more like a `BinaryPredicate ` other than just a `BinaryExpression`.
    
    For the unit tests, the original unit tests are wrong. E.g.,  the test `"SELECT a, b, c FROM oneToTenFiltered WHERE c like '%d'"` should be used to test `StringEndsWith`, but `%d` should be `d%` here.
    
    The original test data for column `c` is some strings like `aaaaaaaa`, `bbbbbbbb`, etc. So `%d` and `d%` both works to get the expected row. It is modified to something like `aaaaAAAA` for differentiating the tests of `StringStartsWith`, `StringEndsWith` and `StringContains`.


---
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-6647][SQL] Make trait StringComparison ...

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

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


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-89371968
  
      [Test build #29678 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/29678/consoleFull) for   PR 5309 at commit [`b176385`](https://github.com/apache/spark/commit/b1763852525a711d4cb6f0f9cdb0910b99a77a09).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.
     * This patch does not change any dependencies.


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-88499550
  
      [Test build #29543 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/29543/consoleFull) for   PR 5309 at commit [`275a493`](https://github.com/apache/spark/commit/275a4936a9cbce478f3cf62e8cad916df752fb0e).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds no public classes.
     * This patch does not change any dependencies.


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-88466471
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/29540/
    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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#discussion_r27736822
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/sources/DataSourceStrategy.scala ---
    @@ -176,6 +176,9 @@ private[sql] object DataSourceStrategy extends Strategy {
           case expressions.Contains(a: Attribute, Literal(v: String, StringType)) =>
             Some(sources.StringContains(a.name, v))
     
    +      case p: expressions.Predicate =>
    --- End diff --
    
    Ok. I am also not very sure about this modification. But seems there is no other proper approach to check possible error in this place.
    
    I will revert this part first.


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#discussion_r27737910
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/sources/FilteredScanSuite.scala ---
    @@ -182,15 +185,15 @@ class FilteredScanSuite extends DataSourceTest {
     
       sqlTest(
         "SELECT a, b, c FROM oneToTenFiltered WHERE c like 'c%'",
    -    Seq(Row(3, 3 * 2, "c" * 10)))
    +    Seq(Row(3, 3 * 2, "c" * 5 + "C" * 5)))
     
       sqlTest(
    -    "SELECT a, b, c FROM oneToTenFiltered WHERE c like 'd%'",
    -    Seq(Row(4, 4 * 2, "d" * 10)))
    +    "SELECT a, b, c FROM oneToTenFiltered WHERE c like '%D'",
    +    Seq(Row(4, 4 * 2, "d" * 5 + "D" * 5)))
     
       sqlTest(
    -    "SELECT a, b, c FROM oneToTenFiltered WHERE c like '%e%'",
    -    Seq(Row(5, 5 * 2, "e" * 10)))
    +    "SELECT a, b, c FROM oneToTenFiltered WHERE c like '%eE%'",
    +    Seq(Row(5, 5 * 2, "e" * 5 + "E" * 5)))
     
       testPushDown("SELECT * FROM oneToTenFiltered WHERE A = 1", 1)
    --- End diff --
    
    Add new `testPushDown` tests now. Thanks.


---
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-6647][SQL] Make trait StringComparison ...

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

    https://github.com/apache/spark/pull/5309#issuecomment-89400601
  
    Thanks!  Merged to 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