You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by MikkelTAndersen <gi...@git.apache.org> on 2017/03/13 09:23:44 UTC

[GitHub] cassandra pull request #98: Fix cassandra 13246

GitHub user MikkelTAndersen opened a pull request:

    https://github.com/apache/cassandra/pull/98

    Fix cassandra 13246

    This should fix null pointer if the content of the column is null.

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

    $ git pull https://github.com/MikkelTAndersen/cassandra fix_CASSANDRA-13246

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

    https://github.com/apache/cassandra/pull/98.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 #98
    
----
commit dac39d0268ba82b6be033e0c63ebd653ae0517cc
Author: Mikkel Andersen <mi...@gmail.com>
Date:   2017-03-13T09:21:27Z

    added null check - see CASSANDRA-13246

commit 145087e3b5d748ce25e8792f91c249d2a05de3e5
Author: Mikkel Andersen <mi...@gmail.com>
Date:   2017-03-13T09:22:53Z

    fixed formatting

----


---
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.
---

[GitHub] cassandra issue #98: Fix cassandra 13246

Posted by blerer <gi...@git.apache.org>.
Github user blerer commented on the issue:

    https://github.com/apache/cassandra/pull/98
  
    @MikkelTAndersen Could you also add some unit tests to your patch?  


---
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.
---

[GitHub] cassandra issue #98: Fix cassandra 13246

Posted by ifesdjeen <gi...@git.apache.org>.
Github user ifesdjeen commented on the issue:

    https://github.com/apache/cassandra/pull/98
  
    Hi @MikkelTAndersen. Cassandra does not use pull requests for Apache Cassandra. Please use JIRA directly.
    
    You can get more information on the contribution process here https://wiki.apache.org/cassandra/HowToContribute


---
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.
---

[GitHub] cassandra issue #98: Fix cassandra 13246

Posted by MikkelTAndersen <gi...@git.apache.org>.
Github user MikkelTAndersen commented on the issue:

    https://github.com/apache/cassandra/pull/98
  
    Thanks Benjamin - I added a test for list, set and map. its all in this
    patch
    
    On Mon, Mar 13, 2017 at 2:02 PM, Benjamin Lerer <no...@github.com>
    wrote:
    
    > You can look into org.apache.cassandra.cql3.validation.entities.
    > SecondaryIndexTest for some examples. It is where you test should go.
    >
    > Otherwise just generate a patch using: git format-patch and attach the
    > output to the JIRA ticket. I guess that the problem must be there since 3.0
    > so the patch should be for this version.
    >
    > \u2014
    > You are receiving this because you were mentioned.
    > Reply to this email directly, view it on GitHub
    > <https://github.com/apache/cassandra/pull/98#issuecomment-286100435>, or mute
    > the thread
    > <https://github.com/notifications/unsubscribe-auth/AACsNmhSUn2vC3WqcTP_BjutuvUp3KRQks5rlT5UgaJpZM4MbArn>
    > .
    >
    
    
    
    -- 
    Venlig Hilsen
    Mikkel T. Andersen
    Skjoldborgvej 8
    7100 Vejle
    Mobil: +45 40 26 79 26
    
    From dac39d0268ba82b6be033e0c63ebd653ae0517cc Mon Sep 17 00:00:00 2001
    From: Mikkel Andersen <mi...@gmail.com>
    Date: Mon, 13 Mar 2017 10:21:27 +0100
    Subject: [PATCH] added null check - see CASSANDRA-13246
    
    ---
     .../org/apache/cassandra/db/filter/RowFilter.java  | 22 ++++++++++++----------
     1 file changed, 12 insertions(+), 10 deletions(-)
    
    diff --git a/src/java/org/apache/cassandra/db/filter/RowFilter.java b/src/java/org/apache/cassandra/db/filter/RowFilter.java
    index bf65e96..c26c1ad 100644
    --- a/src/java/org/apache/cassandra/db/filter/RowFilter.java
    +++ b/src/java/org/apache/cassandra/db/filter/RowFilter.java
    @@ -611,17 +611,19 @@ public abstract class RowFilter implements Iterable<RowFilter.Expression>
                         if (column.isComplex())
                         {
                             ComplexColumnData complexData = row.getComplexColumnData(column);
    -                        for (Cell cell : complexData)
    -                        {
    -                            if (type.kind == CollectionType.Kind.SET)
    -                            {
    -                                if (type.nameComparator().compare(cell.path().get(0), value) == 0)
    -                                    return true;
    -                            }
    -                            else
    +                        if (complexData != null) {
    +                            for (Cell cell : complexData)
                                 {
    -                                if (type.valueComparator().compare(cell.value(), value) == 0)
    -                                    return true;
    +                                if (type.kind == CollectionType.Kind.SET)
    +                                {
    +                                    if (type.nameComparator().compare(cell.path().get(0), value) == 0)
    +                                        return true;
    +                                }
    +                                else
    +                                {
    +                                    if (type.valueComparator().compare(cell.value(), value) == 0)
    +                                        return true;
    +                                }
                                 }
                             }
                             return false;
    -- 
    2.0.1
    
    From 145087e3b5d748ce25e8792f91c249d2a05de3e5 Mon Sep 17 00:00:00 2001
    From: Mikkel Andersen <mi...@gmail.com>
    Date: Mon, 13 Mar 2017 10:22:53 +0100
    Subject: [PATCH] fixed formatting
    
    ---
     src/java/org/apache/cassandra/db/filter/RowFilter.java | 3 ++-
     1 file changed, 2 insertions(+), 1 deletion(-)
    
    diff --git a/src/java/org/apache/cassandra/db/filter/RowFilter.java b/src/java/org/apache/cassandra/db/filter/RowFilter.java
    index c26c1ad..d3fc301 100644
    --- a/src/java/org/apache/cassandra/db/filter/RowFilter.java
    +++ b/src/java/org/apache/cassandra/db/filter/RowFilter.java
    @@ -611,7 +611,8 @@ public abstract class RowFilter implements Iterable<RowFilter.Expression>
                         if (column.isComplex())
                         {
                             ComplexColumnData complexData = row.getComplexColumnData(column);
    -                        if (complexData != null) {
    +                        if (complexData != null)
    +                        {
                                 for (Cell cell : complexData)
                                 {
                                     if (type.kind == CollectionType.Kind.SET)
    -- 
    2.0.1
    
    From ab8e52a26c361483c9af9990037c9fb7abdd7aba Mon Sep 17 00:00:00 2001
    From: Mikkel Andersen <mi...@gmail.com>
    Date: Mon, 13 Mar 2017 15:07:11 +0100
    Subject: [PATCH] added test and fixed documentation
    
    ---
     src/java/org/apache/cassandra/db/rows/Row.java     |  2 +-
     .../validation/entities/SecondaryIndexTest.java    | 39 ++++++++++++++++++++++
     2 files changed, 40 insertions(+), 1 deletion(-)
    
    diff --git a/src/java/org/apache/cassandra/db/rows/Row.java b/src/java/org/apache/cassandra/db/rows/Row.java
    index 04092a6..7449e51 100644
    --- a/src/java/org/apache/cassandra/db/rows/Row.java
    +++ b/src/java/org/apache/cassandra/db/rows/Row.java
    @@ -132,7 +132,7 @@ public interface Row extends Unfiltered, Collection<ColumnData>
          * The returned object groups all the cells for the column, as well as it's complex deletion (if relevant).
          *
          * @param c the complex column for which to return the complex data.
    -     * @return the data for {@code c} or {@code null} is the row has no data for this column.
    +     * @return the data for {@code c} or {@code null} if the row has no data for this column.
          */
         public ComplexColumnData getComplexColumnData(ColumnMetadata c);
     
    diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
    index c00688d..68a3378 100644
    --- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
    +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
    @@ -430,6 +430,45 @@ public class SecondaryIndexTest extends CQLTester
             });
         }
     
    +    @Test
    +    public void testSelectOnMultiIndexOnCollectionsWithNull() throws Throwable
    +    {
    +        createTable(" CREATE TABLE %s ( k int, v int, x text, l list<int>, s set<text>, m map<text, int>, PRIMARY KEY (k, v))");
    +
    +        createIndex("CREATE INDEX ON %s (x)");
    +        createIndex("CREATE INDEX ON %s (v)");
    +        createIndex("CREATE INDEX ON %s (s)");
    +        createIndex("CREATE INDEX ON %s (m)");
    +
    +
    +        execute("INSERT INTO %s (k, v, x, l, s, m) VALUES (0, 0, 'x', [1, 2],    {'a'},      {'a' : 1})");
    +        execute("INSERT INTO %s (k, v, x, l, s, m) VALUES (0, 1, 'x', [3, 4],    {'b', 'c'}, {'a' : 1, 'b' : 2})");
    +        execute("INSERT INTO %s (k, v, x, l, s, m) VALUES (0, 2, 'x', [1],       {'a', 'c'}, {'c' : 3})");
    +        execute("INSERT INTO %s (k, v, x, l, s, m) VALUES (1, 0, 'x', [1, 2, 4], {},         {'b' : 1})");
    +        execute("INSERT INTO %s (k, v, x, l, s, m) VALUES (1, 1, 'x', [4, 5],    {'d'},      {'a' : 1, 'b' : 3})");
    +        execute("INSERT INTO %s (k, v, x, l, s, m) VALUES (1, 2, 'x', null,      null,       null)");
    +
    +        beforeAndAfterFlush(() -> {
    +            // lists
    +            assertRows(execute("SELECT k, v FROM %s WHERE x = 'x' AND l CONTAINS 1 ALLOW FILTERING"), row(1, 0), row(0, 0), row(0, 2));
    +            assertRows(execute("SELECT k, v FROM %s WHERE x = 'x' AND k = 0 AND l CONTAINS 1 ALLOW FILTERING"), row(0, 0), row(0, 2));
    +            assertRows(execute("SELECT k, v FROM %s WHERE x = 'x' AND l CONTAINS 2 ALLOW FILTERING"), row(1, 0), row(0, 0));
    +            assertEmpty(execute("SELECT k, v FROM %s WHERE x = 'x' AND l CONTAINS 6 ALLOW FILTERING"));
    +
    +            // sets
    +            assertRows(execute("SELECT k, v FROM %s WHERE x = 'x' AND s CONTAINS 'a' ALLOW FILTERING" ), row(0, 0), row(0, 2));
    +            assertRows(execute("SELECT k, v FROM %s WHERE x = 'x' AND k = 0 AND s CONTAINS 'a' ALLOW FILTERING"), row(0, 0), row(0, 2));
    +            assertRows(execute("SELECT k, v FROM %s WHERE x = 'x' AND s CONTAINS 'd' ALLOW FILTERING"), row(1, 1));
    +            assertEmpty(execute("SELECT k, v FROM %s  WHERE x = 'x' AND s CONTAINS 'e' ALLOW FILTERING"));
    +
    +            // maps
    +            assertRows(execute("SELECT k, v FROM %s WHERE x = 'x' AND m CONTAINS 1 ALLOW FILTERING"), row(1, 0), row(1, 1), row(0, 0), row(0, 1));
    +            assertRows(execute("SELECT k, v FROM %s WHERE x = 'x' AND k = 0 AND m CONTAINS 1 ALLOW FILTERING"), row(0, 0), row(0, 1));
    +            assertRows(execute("SELECT k, v FROM %s WHERE x = 'x' AND m CONTAINS 2 ALLOW FILTERING"), row(0, 1));
    +            assertEmpty(execute("SELECT k, v FROM %s  WHERE x = 'x' AND m CONTAINS 4 ALLOW FILTERING"));
    +        });
    +    }
    +
         /**
          * Migrated from cql_tests.py:TestCQL.map_keys_indexing()
          */
    -- 
    2.0.1
    



---
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.
---

[GitHub] cassandra pull request #98: Fix cassandra 13246

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

    https://github.com/apache/cassandra/pull/98


---
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.
---

[GitHub] cassandra issue #98: Fix cassandra 13246

Posted by MikkelTAndersen <gi...@git.apache.org>.
Github user MikkelTAndersen commented on the issue:

    https://github.com/apache/cassandra/pull/98
  
    Ahh sorry - it seems to complicated, its a simple null check - any chance
    you can add it Alex ? I have attached the patch.
    
    On Mon, Mar 13, 2017 at 1:38 PM, Alex Petrov <no...@github.com>
    wrote:
    
    > Hi @MikkelTAndersen <https://github.com/MikkelTAndersen>. Cassandra does
    > not use pull requests for Apache Cassandra. Please use JIRA directly.
    >
    > You can get more information on the contribution process here
    > https://wiki.apache.org/cassandra/HowToContribute
    >
    > \u2014
    > You are receiving this because you were mentioned.
    > Reply to this email directly, view it on GitHub
    > <https://github.com/apache/cassandra/pull/98#issuecomment-286095410>, or mute
    > the thread
    > <https://github.com/notifications/unsubscribe-auth/AACsNo9UVdqa6Ygr4N2jwfUj-0ithzS7ks5rlTi8gaJpZM4MbArn>
    > .
    >
    
    
    
    -- 
    Venlig Hilsen
    Mikkel T. Andersen
    Skjoldborgvej 8
    7100 Vejle
    Mobil: +45 40 26 79 26
    
    From dac39d0268ba82b6be033e0c63ebd653ae0517cc Mon Sep 17 00:00:00 2001
    From: Mikkel Andersen <mi...@gmail.com>
    Date: Mon, 13 Mar 2017 10:21:27 +0100
    Subject: [PATCH] added null check - see CASSANDRA-13246
    
    ---
     .../org/apache/cassandra/db/filter/RowFilter.java  | 22 ++++++++++++----------
     1 file changed, 12 insertions(+), 10 deletions(-)
    
    diff --git a/src/java/org/apache/cassandra/db/filter/RowFilter.java b/src/java/org/apache/cassandra/db/filter/RowFilter.java
    index bf65e96..c26c1ad 100644
    --- a/src/java/org/apache/cassandra/db/filter/RowFilter.java
    +++ b/src/java/org/apache/cassandra/db/filter/RowFilter.java
    @@ -611,17 +611,19 @@ public abstract class RowFilter implements Iterable<RowFilter.Expression>
                         if (column.isComplex())
                         {
                             ComplexColumnData complexData = row.getComplexColumnData(column);
    -                        for (Cell cell : complexData)
    -                        {
    -                            if (type.kind == CollectionType.Kind.SET)
    -                            {
    -                                if (type.nameComparator().compare(cell.path().get(0), value) == 0)
    -                                    return true;
    -                            }
    -                            else
    +                        if (complexData != null) {
    +                            for (Cell cell : complexData)
                                 {
    -                                if (type.valueComparator().compare(cell.value(), value) == 0)
    -                                    return true;
    +                                if (type.kind == CollectionType.Kind.SET)
    +                                {
    +                                    if (type.nameComparator().compare(cell.path().get(0), value) == 0)
    +                                        return true;
    +                                }
    +                                else
    +                                {
    +                                    if (type.valueComparator().compare(cell.value(), value) == 0)
    +                                        return true;
    +                                }
                                 }
                             }
                             return false;
    -- 
    2.0.1
    
    From 145087e3b5d748ce25e8792f91c249d2a05de3e5 Mon Sep 17 00:00:00 2001
    From: Mikkel Andersen <mi...@gmail.com>
    Date: Mon, 13 Mar 2017 10:22:53 +0100
    Subject: [PATCH] fixed formatting
    
    ---
     src/java/org/apache/cassandra/db/filter/RowFilter.java | 3 ++-
     1 file changed, 2 insertions(+), 1 deletion(-)
    
    diff --git a/src/java/org/apache/cassandra/db/filter/RowFilter.java b/src/java/org/apache/cassandra/db/filter/RowFilter.java
    index c26c1ad..d3fc301 100644
    --- a/src/java/org/apache/cassandra/db/filter/RowFilter.java
    +++ b/src/java/org/apache/cassandra/db/filter/RowFilter.java
    @@ -611,7 +611,8 @@ public abstract class RowFilter implements Iterable<RowFilter.Expression>
                         if (column.isComplex())
                         {
                             ComplexColumnData complexData = row.getComplexColumnData(column);
    -                        if (complexData != null) {
    +                        if (complexData != null)
    +                        {
                                 for (Cell cell : complexData)
                                 {
                                     if (type.kind == CollectionType.Kind.SET)
    -- 
    2.0.1
    



---
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.
---

[GitHub] cassandra issue #98: Fix cassandra 13246

Posted by blerer <gi...@git.apache.org>.
Github user blerer commented on the issue:

    https://github.com/apache/cassandra/pull/98
  
    You can look into `org.apache.cassandra.cql3.validation.entities.SecondaryIndexTest` for some examples. It is where you test should go.
    
    Otherwise just generate a patch using: `git format-patch` and attach the output to the JIRA ticket. I guess that the problem must be there since 3.0 so the patch should be for this version. 


---
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.
---

[GitHub] cassandra issue #98: Fix cassandra 13246

Posted by MikkelTAndersen <gi...@git.apache.org>.
Github user MikkelTAndersen commented on the issue:

    https://github.com/apache/cassandra/pull/98
  
    This is a simple fix for when you query with CONTAINS and the collection is empty (which ends up as null in the database) ... this is a blocking issue for my company so would appreciate if it could get into the next release.


---
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.
---

[GitHub] cassandra issue #98: Fix cassandra 13246

Posted by MikkelTAndersen <gi...@git.apache.org>.
Github user MikkelTAndersen commented on the issue:

    https://github.com/apache/cassandra/pull/98
  
    If anything is missing please let me know and I will fix it asap...
    
    Den 13. mar. 2017 3.09 PM skrev "Mikkel Andersen" <
    mikkel.t.andersen@gmail.com>:
    
    > Thanks Benjamin - I added a test for list, set and map. its all in this
    > patch
    >
    > On Mon, Mar 13, 2017 at 2:02 PM, Benjamin Lerer <no...@github.com>
    > wrote:
    >
    >> You can look into org.apache.cassandra.cql3.vali
    >> dation.entities.SecondaryIndexTest for some examples. It is where you
    >> test should go.
    >>
    >> Otherwise just generate a patch using: git format-patch and attach the
    >> output to the JIRA ticket. I guess that the problem must be there since 3.0
    >> so the patch should be for this version.
    >>
    >> \u2014
    >> You are receiving this because you were mentioned.
    >> Reply to this email directly, view it on GitHub
    >> <https://github.com/apache/cassandra/pull/98#issuecomment-286100435>, or mute
    >> the thread
    >> <https://github.com/notifications/unsubscribe-auth/AACsNmhSUn2vC3WqcTP_BjutuvUp3KRQks5rlT5UgaJpZM4MbArn>
    >> .
    >>
    >
    >
    >
    > --
    > Venlig Hilsen
    > Mikkel T. Andersen
    > Skjoldborgvej 8
    > 7100 Vejle
    > Mobil: +45 40 26 79 26 <40%2026%2079%2026>
    >



---
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.
---

[GitHub] cassandra issue #98: Fix cassandra 13246

Posted by MikkelTAndersen <gi...@git.apache.org>.
Github user MikkelTAndersen commented on the issue:

    https://github.com/apache/cassandra/pull/98
  
    I will see what you have already then : )
    
    On Mon, Mar 13, 2017 at 1:44 PM, Benjamin Lerer <no...@github.com>
    wrote:
    
    > @MikkelTAndersen <https://github.com/MikkelTAndersen> Could you also add
    > some unit tests to your patch?
    >
    > \u2014
    > You are receiving this because you were mentioned.
    > Reply to this email directly, view it on GitHub
    > <https://github.com/apache/cassandra/pull/98#issuecomment-286096659>, or mute
    > the thread
    > <https://github.com/notifications/unsubscribe-auth/AACsNiBxflXgR0Ut57bnugs3_US3N0Y_ks5rlTopgaJpZM4MbArn>
    > .
    >
    
    
    
    -- 
    Venlig Hilsen
    Mikkel T. Andersen
    Skjoldborgvej 8
    7100 Vejle
    Mobil: +45 40 26 79 26



---
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.
---

[GitHub] cassandra issue #98: Fix cassandra 13246

Posted by jeffjirsa <gi...@git.apache.org>.
Github user jeffjirsa commented on the issue:

    https://github.com/apache/cassandra/pull/98
  
    Looks like this was committed as 0eebc6e6b7cd7fc801579e57701608e7bf155ee0 - please do close the PR when you can (the project is unable to close it for you, which is one of the reasons we tend not to use GH PRs). 


---
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.
---