strapdata / elassandra

Elassandra = Elasticsearch + Apache Cassandra
http://www.elassandra.io
Apache License 2.0
1.71k stars 199 forks source link

Cannot create indexes in case the table has materialized views #274

Closed silviucpp closed 5 years ago

silviucpp commented 5 years ago

Hello,

Using Elassandra version: v6.2.3.12

I created a keyspace test_keyspace and one table that has a view:

CREATE TABLE numbers(number text, account_uuid timeuuid, type int, state text, country_code text, purchase_date timestamp, release_date timestamp, status int, PRIMARY KEY(number));

CREATE MATERIALIZED VIEW numbers_by_user AS SELECT * FROM numbers WHERE number IS NOT NULL AND account_uuid IS NOT NULL PRIMARY KEY (account_uuid, number);

When trying to create a mapping as follow:

curl -XPUT "http://172.17.33.171:9200/test_numbers" -H 'Content-Type: application/json' -d '
{
    "settings" : { "keyspace" : "test_keyspace" },
    "mappings": {
        "numbers": {
            "_field_names": {"enabled": false},
            "discover": "number|type|state|contry_code|status"
        }
   }
}'

I get the following error:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Multiple entries with same key: numbers_by_user=org.apache.cassandra.config.ViewDefinition@5cc77036[ksName=test_keyspace,viewName=numbers_by_user,baseTableId=7ba3ee50-5aa7-11e9-b32c-7fa424e5960d,baseTableName=numbers,includeAllColumns=true,whereClause=number IS NOT NULL AND account_uuid IS NOT NULL,metadata=org.apache.cassandra.config.CFMetaData@7429ad08[cfId=8600abe0-5aa7-11e9-b32c-7fa424e5960d,ksName=test_keyspace,cfName=numbers_by_user,flags=[COMPOUND],params=TableParams{comment=, read_repair_chance=0.0, dclocal_read_repair_chance=0.1, bloom_filter_fp_chance=0.01, crc_check_chance=1.0, gc_grace_seconds=864000, default_time_to_live=0, memtable_flush_period_in_ms=0, min_index_interval=128, max_index_interval=2048, speculative_retry=99PERCENTILE, caching={'keys' : 'ALL', 'rows_per_partition' : 'NONE'}, compaction=CompactionParams{class=org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy, options={max_threshold=32, min_threshold=4}}, compression=org.apache.cassandra.schema.CompressionParams@bbfbd591, extensions={}, cdc=false},comparator=comparator(org.apache.cassandra.db.marshal.UTF8Type),partitionColumns=[[] | [country_code purchase_date release_date state status type]],partitionKeyColumns=[account_uuid],clusteringColumns=[number],keyValidator=org.apache.cassandra.db.marshal.TimeUUIDType,columnMetadata=[number, country_code, status, purchase_date, release_date, state, type, account_uuid],droppedColumns={},triggers=[],indexes=[]]] and numbers_by_user=org.apache.cassandra.config.ViewDefinition@5cc77036[ksName=test_keyspace,viewName=numbers_by_user,baseTableId=7ba3ee50-5aa7-11e9-b32c-7fa424e5960d,baseTableName=numbers,includeAllColumns=true,whereClause=number IS NOT NULL AND account_uuid IS NOT NULL,metadata=org.apache.cassandra.config.CFMetaData@7429ad08[cfId=8600abe0-5aa7-11e9-b32c-7fa424e5960d,ksName=test_keyspace,cfName=numbers_by_user,flags=[COMPOUND],params=TableParams{comment=, read_repair_chance=0.0, dclocal_read_repair_chance=0.1, bloom_filter_fp_chance=0.01, crc_check_chance=1.0, gc_grace_seconds=864000, default_time_to_live=0, memtable_flush_period_in_ms=0, min_index_interval=128, max_index_interval=2048, speculative_retry=99PERCENTILE, caching={'keys' : 'ALL', 'rows_per_partition' : 'NONE'}, compaction=CompactionParams{class=org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy, options={max_threshold=32, min_threshold=4}}, compression=org.apache.cassandra.schema.CompressionParams@bbfbd591, extensions={}, cdc=false},comparator=comparator(org.apache.cassandra.db.marshal.UTF8Type),partitionColumns=[[] | [country_code purchase_date release_date state status type]],partitionKeyColumns=[account_uuid],clusteringColumns=[number],keyValidator=org.apache.cassandra.db.marshal.TimeUUIDType,columnMetadata=[number, country_code, status, purchase_date, release_date, state, type, account_uuid],droppedColumns={},triggers=[],indexes=[]]]"}],"type":"mapper_parsing_exception","reason":"Multiple entries with same key: numbers_by_user=org.apache.cassandra.config.ViewDefinition@5cc77036[ksName=test_keyspace,viewName=numbers_by_user,baseTableId=7ba3ee50-5aa7-11e9-b32c-7fa424e5960d,baseTableName=numbers,includeAllColumns=true,whereClause=number IS NOT NULL AND account_uuid IS NOT NULL,metadata=org.apache.cassandra.config.CFMetaData@7429ad08[cfId=8600abe0-5aa7-11e9-b32c-7fa424e5960d,ksName=test_keyspace,cfName=numbers_by_user,flags=[COMPOUND],params=TableParams{comment=, read_repair_chance=0.0, dclocal_read_repair_chance=0.1, bloom_filter_fp_chance=0.01, crc_check_chance=1.0, gc_grace_seconds=864000, default_time_to_live=0, memtable_flush_period_in_ms=0, min_index_interval=128, max_index_interval=2048, speculative_retry=99PERCENTILE, caching={'keys' : 'ALL', 'rows_per_partition' : 'NONE'}, compaction=CompactionParams{class=org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy, options={max_threshold=32, min_threshold=4}}, compression=org.apache.cassandra.schema.CompressionParams@bbfbd591, extensions={}, cdc=false},comparator=comparator(org.apache.cassandra.db.marshal.UTF8Type),partitionColumns=[[] | [country_code purchase_date release_date state status type]],partitionKeyColumns=[account_uuid],clusteringColumns=[number],keyValidator=org.apache.cassandra.db.marshal.TimeUUIDType,columnMetadata=[number, country_code, status, purchase_date, release_date, state, type, account_uuid],droppedColumns={},triggers=[],indexes=[]]] and numbers_by_user=org.apache.cassandra.config.ViewDefinition@5cc77036[ksName=test_keyspace,viewName=numbers_by_user,baseTableId=7ba3ee50-5aa7-11e9-b32c-7fa424e5960d,baseTableName=numbers,includeAllColumns=true,whereClause=number IS NOT NULL AND account_uuid IS NOT NULL,metadata=org.apache.cassandra.config.CFMetaData@7429ad08[cfId=8600abe0-5aa7-11e9-b32c-7fa424e5960d,ksName=test_keyspace,cfName=numbers_by_user,flags=[COMPOUND],params=TableParams{comment=, read_repair_chance=0.0, dclocal_read_repair_chance=0.1, bloom_filter_fp_chance=0.01, crc_check_chance=1.0, gc_grace_seconds=864000, default_time_to_live=0, memtable_flush_period_in_ms=0, min_index_interval=128, max_index_interval=2048, speculative_retry=99PERCENTILE, caching={'keys' : 'ALL', 'rows_per_partition' : 'NONE'}, compaction=CompactionParams{class=org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy, options={max_threshold=32, min_threshold=4}}, compression=org.apache.cassandra.schema.CompressionParams@bbfbd591, extensions={}, cdc=false},comparator=comparator(org.apache.cassandra.db.marshal.UTF8Type),partitionColumns=[[] | [country_code purchase_date release_date state status type]],partitionKeyColumns=[account_uuid],clusteringColumns=[number],keyValidator=org.apache.cassandra.db.marshal.TimeUUIDType,columnMetadata=[number, country_code, status, purchase_date, release_date, state, type, account_uuid],droppedColumns={},triggers=[],indexes=[]]]","caused_by":{"type":"illegal_argument_exception","reason":"Multiple entries with same key: numbers_by_user=org.apache.cassandra.config.ViewDefinition@5cc77036[ksName=test_keyspace,viewName=numbers_by_user,baseTableId=7ba3ee50-5aa7-11e9-b32c-7fa424e5960d,baseTableName=numbers,includeAllColumns=true,whereClause=number IS NOT NULL AND account_uuid IS NOT NULL,metadata=org.apache.cassandra.config.CFMetaData@7429ad08[cfId=8600abe0-5aa7-11e9-b32c-7fa424e5960d,ksName=test_keyspace,cfName=numbers_by_user,flags=[COMPOUND],params=TableParams{comment=, read_repair_chance=0.0, dclocal_read_repair_chance=0.1, bloom_filter_fp_chance=0.01, crc_check_chance=1.0, gc_grace_seconds=864000, default_time_to_live=0, memtable_flush_period_in_ms=0, min_index_interval=128, max_index_interval=2048, speculative_retry=99PERCENTILE, caching={'keys' : 'ALL', 'rows_per_partition' : 'NONE'}, compaction=CompactionParams{class=org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy, options={max_threshold=32, min_threshold=4}}, compression=org.apache.cassandra.schema.CompressionParams@bbfbd591, extensions={}, cdc=false},comparator=comparator(org.apache.cassandra.db.marshal.UTF8Type),partitionColumns=[[] | [country_code purchase_date release_date state status type]],partitionKeyColumns=[account_uuid],clusteringColumns=[number],keyValidator=org.apache.cassandra.db.marshal.TimeUUIDType,columnMetadata=[number, country_code, status, purchase_date, release_date, state, type, account_uuid],droppedColumns={},triggers=[],indexes=[]]] and numbers_by_user=org.apache.cassandra.config.ViewDefinition@5cc77036[ksName=test_keyspace,viewName=numbers_by_user,baseTableId=7ba3ee50-5aa7-11e9-b32c-7fa424e5960d,baseTableName=numbers,includeAllColumns=true,whereClause=number IS NOT NULL AND account_uuid IS NOT NULL,metadata=org.apache.cassandra.config.CFMetaData@7429ad08[cfId=8600abe0-5aa7-11e9-b32c-7fa424e5960d,ksName=test_keyspace,cfName=numbers_by_user,flags=[COMPOUND],params=TableParams{comment=, read_repair_chance=0.0, dclocal_read_repair_chance=0.1, bloom_filter_fp_chance=0.01, crc_check_chance=1.0, gc_grace_seconds=864000, default_time_to_live=0, memtable_flush_period_in_ms=0, min_index_interval=128, max_index_interval=2048, speculative_retry=99PERCENTILE, caching={'keys' : 'ALL', 'rows_per_partition' : 'NONE'}, compaction=CompactionParams{class=org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy, options={max_threshold=32, min_threshold=4}}, compression=org.apache.cassandra.schema.CompressionParams@bbfbd591, extensions={}, cdc=false},comparator=comparator(org.apache.cassandra.db.marshal.UTF8Type),partitionColumns=[[] | [country_code purchase_date release_date state status type]],partitionKeyColumns=[account_uuid],clusteringColumns=[number],keyValidator=org.apache.cassandra.db.marshal.TimeUUIDType,columnMetadata=[number, country_code, status, purchase_date, release_date, state, type, account_uuid],droppedColumns={},triggers=[],indexes=[]]]"}},"status":400}

If there is no materialized view created it's working.

silviucpp commented 5 years ago

Also If I create the mapping before the materialized views it's ok .

vroyer commented 5 years ago

Hi, Yes, it's a bug, fixed in this commit and will be included in the next release. Thanks.

silviucpp commented 5 years ago

Great !

Thanks a lot for update

vroyer commented 5 years ago

This is fixed in release 6.2.3.14. Thanks for reporting the issue.

silviucpp commented 5 years ago

Yes it's fixed. I can confirm.