Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - exclude empty map / list / set from sparse data return #1690

Closed
amorton opened this issue Nov 12, 2024 · 1 comment
Closed

Bug - exclude empty map / list / set from sparse data return #1690

amorton opened this issue Nov 12, 2024 · 1 comment
Assignees
Labels
Bug Something isn't working

Comments

@amorton
Copy link
Contributor

amorton commented Nov 12, 2024

If we have this table and data

CREATE TABLE collections (
   key            text,
   list_type      list<text>,
   set_type        set<text>,
   map_type       map<text, text>,
   PRIMARY KEY (key)
);

CREATE INDEX list_type_idx ON collections (VALUES(list_type));

CREATE INDEX set_type_idx ON collections (VALUES(set_type));

CREATE INDEX map_keys_idx ON collections (KEYS(map_type));

CREATE INDEX map_values_idx ON collections (VALUES(map_type));

CREATE INDEX map_entries_idx ON collections (ENTRIES(map_type));

insert into collections (key, list_type, set_type, map_type) values('map-row-nulls', null, null, {'map_key' : 'map_value'});


insert into collections (key, list_type, set_type, map_type) values('map-row-empty', [], {}, {'map_key' : 'map_value'});

CQLSH looks like this

cassandra@cqlsh:demo> select * from collections;

 key           | list_type | map_type                 | set_type
---------------+-----------+--------------------------+----------
       map-row |      null | {'map_key': 'map_value'} |     null
 map-row-nulls |      null | {'map_key': 'map_value'} |     null
 map-row-empty |      null | {'map_key': 'map_value'} |     null

And the API will return

{
  "find": {
      "filter" : {},
      "projection" : {},
      "sort" : {},
      "options" : {}
}}

{
    "data": {
        "documents": [
            {
                "list_type": [],
                "map_type": {
                    "map_key": "map_value"
                },
                "set_type": [],
                "key": "map-row"
            },
            {
                "list_type": [],
                "map_type": {
                    "map_key": "map_value"
                },
                "set_type": [],
                "key": "map-row-nulls"
            },
            {
                "list_type": [],
                "map_type": {
                    "map_key": "map_value"
                },
                "set_type": [],
                "key": "map-row-empty"
            }
        ],
        "nextPageState": null
    },
    "status": {
        "warnings": [
            {
                "errorCode": "ZERO_FILTER_OPERATIONS",
                "message": "Zero filters were provided in the filter for this query. \n\nProviding zero filters will return all rows in the table, which may have poor performance when the table is large. For the best performance, include one or more filters using the primary key or indexes.\n\nThe table demo.collections has the primary key: key(text).\nAnd has indexes on the columns: values(list_type), entries(map_type), keys(map_type), values(map_type), values(set_type).\n\nThe query was executed without taking advantage of the primary key or indexes on the table, this can have performance implications on large tables.\n\nSee documentation at XXXX for best practices for filtering.",
                "family": "REQUEST",
                "scope": "WARNING",
                "title": "Zero operations provided in query filter",
                "id": "5db56e11-2efe-490e-a616-57586bd9ab09"
            }
        ],
        "projectionSchema": {
            "list_type": {
                "type": "list",
                "valueType": "text"
            },
            "map_type": {
                "type": "map",
                "keyType": "text",
                "valueType": "text"
            },
            "set_type": {
                "type": "set",
                "valueType": "text"
            },
            "key": {
                "type": "text"
            }
        }
    }
}

The driver will auto turn a null for a collection type into the empty instance of the type, and we have no way of knowing the difference between null and empty.

the idea of sparse data is to avoid sending data that conveys no information, so we should exclude empty collections from the result.

@amorton amorton added the Bug Something isn't working label Nov 12, 2024
@Yuqi-Du
Copy link
Contributor

Yuqi-Du commented Nov 13, 2024

fixed:
#1694

@Yuqi-Du Yuqi-Du closed this as completed Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants