Skip to content

createIndex on lists accepts $keys and treats it as $values #2236

@sl-at-ibm

Description

@sl-at-ibm

The createIndex command accepts a payload such as:

{"createIndex":{"name":"idx3","definition":{"column":{"lt":"$keys"}},"options":{}}}

where lt is a LIST<TEXT> (presumably the same for sets).

The resulting index is of course on the values, as CQL shows:

CREATE CUSTOM INDEX idx3 ON default_keyspace.t (values(lt)) USING 'StorageAttachedIndex';

i.e. the same effect as the expected API payload with {"lt":"$values"}.

Incidentally:

the fact that the API accepts a payload with indexing function for lists and sets at all is not stated on the error message that gives guidance:

      Command has an invalid format for index creation column.
      
      The column string can have different formats:
      - Primitive column: {"column": "primitiveColumn"}
      - List column: {"column": "listColumn"}
      - Set column: {"column": "setColumn"}
      - Map column:
        - Default to index on map entries: {"column": "mapColumn"}
        - Index on map keys: {"column": {"mapColumn" : "$keys"}}
        - Index on map values: {"column": {"mapColumn" : "$values"}}
      
      Resend the command using a valid format for index creation column.

I guess this is OK, just wanted to make this point explicit. The (likely) bug is the one above, with $keys being treated as $values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions