You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Henrik Ring (JIRA)" <ji...@apache.org> on 2012/11/05 17:10:13 UTC

[jira] [Comment Edited] (CASSANDRA-4909) Bug when composite index is created in a table having collections

    [ https://issues.apache.org/jira/browse/CASSANDRA-4909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13490697#comment-13490697 ] 

Henrik Ring edited comment on CASSANDRA-4909 at 11/5/12 4:08 PM:
-----------------------------------------------------------------

Working at the ApacheConEU Hackathon. Suggestions for testing the patch.
Below is my understanding of the issue and the solution and a suggestion for how to test it.

The patch changes the code so the exception: InvalidRequestException("Indexes on collections are no yet supported")
is raised if an attempt is made to create an index on an collection type column.

Creation of indexes on tables that have collection column values is allowed as long as 
the collection columns are NOT part of the index. 

Tests:
In CQL3 create CF with 2 collection type columns "A1" and "A2" and 2 noncollection type columns "B1" and "B2".
Create index on A1 or A2 should fail. 
Create an index on B1 or B2 should succeed.
Insert data.
Select on column with index to ensure index is in place.

-- Should succeed
CREATE KEYSPACE TEST_CASSANDRA_4909_KS;

-- Should succeed
USE TEST_CASSANDRA_4909_KS; 

-- Should succeed
CREATE TABLE TEST_CASSANDRA_4909_TLB1
   (A1 set<text>,
    A2 set<text>,
    B1 text,
    B2 text,
    PRIMARY KEY B1);

-- Should fail: InvalidRequestException("Indexes on collections are no yet supported")
CREATE INDEX TEST_CASSANDRA_4909_TLB1_INX1 ON TEST_CASSANDRA_4909_TLB1 (A1);

-- Should Succeed:
CREATE INDEX TEST_CASSANDRA_4909_TLB1_INX2 ON TEST_CASSANDRA_4909_TLB1 (B2);

-- Wait for schema agreement.

-- Should succeed:
INSERT INTO TEST_CASSANDRA_4909_TLB1 (A1, A2, B1, B2)
       VALUES({'A1-ROW1-ELM-1', 'A1-ROW1-ELM2'}, {'A2-ROW1-ELM-1', 'A2-ROW1-ELM2'}, 'B1-ROW1', 'B2-ROW1' );

-- Should succeed:
INSERT INTO TEST_CASSANDRA_4909_TLB1 (A1, A2, B1, B2)
       VALUES({'A1-ROW2-ELM-1', 'A1-ROW2-ELM2'}, {'A2-ROW2-ELM-1', 'A2-ROW2-ELM2'}, 'B1-ROW2', 'B2-ROW2' );

-- Should succeed (ensure index is in place):
SELECT * FROM TEST_CASSANDRA_4909_TLB1 WHERE B2 = 'B2-ROW2';

-- Should succeed:
DROP TABLE TEST_CASSANDRA_4909_TLB1;

                
      was (Author: henrikring):
    Working at the ApacheConEU Hackathon. Suggestions for testing the patch.

The patch changes the code so the exception: InvalidRequestException("Indexes on collections are no yet supported")
is raised if an attempt is made to create an index on an collection type column.

Creation of indexes on tables that have collection column values is allowed as long as 
the collection columns are NOT part of the index. 

Tests:
In CQL3 create CF with 2 collection type columns "A1" and "A2" and 2 noncollection type columns "B1" and "B2".
Create index on A1 or A2 should fail. 
Create an index on B1 or B2 should succeed.
Insert data.
Select on column with index to ensure index is in place.

-- Should succeed
CREATE KEYSPACE TEST_CASSANDRA_4909_KS;

-- Should succeed
USE TEST_CASSANDRA_4909_KS; 

-- Should succeed
CREATE TABLE TEST_CASSANDRA_4909_TLB1
   (A1 set<text>,
    A2 set<text>,
    B1 text,
    B2 text,
    PRIMARY KEY B1);

-- Should fail: InvalidRequestException("Indexes on collections are no yet supported")
CREATE INDEX TEST_CASSANDRA_4909_TLB1_INX1 ON TEST_CASSANDRA_4909_TLB1 (A1);

-- Should Succeed:
CREATE INDEX TEST_CASSANDRA_4909_TLB1_INX2 ON TEST_CASSANDRA_4909_TLB1 (B2);

-- Wait for schema agreement.

-- Should succeed:
INSERT INTO TEST_CASSANDRA_4909_TLB1 (A1, A2, B1, B2)
       VALUES({'A1-ROW1-ELM-1', 'A1-ROW1-ELM2'}, {'A2-ROW1-ELM-1', 'A2-ROW1-ELM2'}, 'B1-ROW1', 'B2-ROW1' );

-- Should succeed:
INSERT INTO TEST_CASSANDRA_4909_TLB1 (A1, A2, B1, B2)
       VALUES({'A1-ROW2-ELM-1', 'A1-ROW2-ELM2'}, {'A2-ROW2-ELM-1', 'A2-ROW2-ELM2'}, 'B1-ROW2', 'B2-ROW2' );

-- Should succeed (ensure index is in place):
SELECT * FROM TEST_CASSANDRA_4909_TLB1 WHERE B2 = 'B2-ROW2';

-- Should succeed:
DROP TABLE TEST_CASSANDRA_4909_TLB1;

                  
> Bug when composite index is created in a table having collections
> -----------------------------------------------------------------
>
>                 Key: CASSANDRA-4909
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-4909
>             Project: Cassandra
>          Issue Type: Bug
>    Affects Versions: 1.2.0 beta 1
>            Reporter: Sylvain Lebresne
>            Assignee: Sylvain Lebresne
>             Fix For: 1.2.0 beta 2
>
>         Attachments: 4909.txt
>
>
> CASSANDRA-4511 is open to add proper indexing of collection, but currently indexing doesn't work correctly if we index a value in a table having collection, even if that value is not a collection itself.
> We also don't refuse creating index on collections, even though we don't support it. Attaching patch to fix both.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira