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

YCQL index name is optional in Cassandra #1031

Closed
BevanR opened this issue Mar 19, 2019 · 1 comment
Closed

YCQL index name is optional in Cassandra #1031

BevanR opened this issue Mar 19, 2019 · 1 comment
Assignees
Labels
community/request Issues created by external users kind/enhancement This is an enhancement of an existing feature

Comments

@BevanR
Copy link

BevanR commented Mar 19, 2019

Index name is required in YCQL but optional in Cassandra CQL. This causes problems with tools like ORM; masumsoft/express-cassandra#197

@kmuthukk kmuthukk added the ycql label Mar 20, 2019
@kmuthukk kmuthukk added the kind/enhancement This is an enhancement of an existing feature label Mar 20, 2019
yugabyte-ci pushed a commit that referenced this issue Mar 27, 2019
Summary:
Added ability to use empty (automatic) name in CREATE INDEX statement.
The automatic name is in the format:  `table-name_column-name1_column-name2_idx`. (Using only primary key columns:  partitioning-columns and clustering-columns. Covering-columns are not used in the index naming. Using only columns which were added in the statement explicitly, automatically added columns are not used.)

For example:
```
> CREATE TABLE human_resource1 (id int primary key, name varchar) with transactions = {'enabled':true};
> CREATE INDEX ON human_resource1(name);
> DESC TABLE human_resource1;

CREATE TABLE a.human_resource1 (
    id int PRIMARY KEY,
    name text
) WITH default_time_to_live = 0
    AND transactions = {'enabled': 'true'};
CREATE INDEX human_resource1_name_idx ON a.human_resource1 (name, id)
    WITH transactions = {'enabled': 'true'};
```
The Index name here will be:  `human_resource1_name_idx` (column 'id' will be added as a clustering-column automatically, so it's not used for the Index name).

Indexes can be on multiple columns. For example:

```
> CREATE INDEX ON human_resource1(name, id);
> DESC TABLE human_resource1;

CREATE TABLE a.human_resource1 (
    id int PRIMARY KEY,
    name text
) WITH default_time_to_live = 0
    AND transactions = {'enabled': 'true'};
CREATE INDEX human_resource1_name_id_idx ON a.human_resource1 (name, id)
    WITH transactions = {'enabled': 'true'};
CREATE INDEX human_resource1_name_idx ON a.human_resource1 (name, id)
    WITH transactions = {'enabled': 'true'};
```

In this case all explicitly used columns will be mentioned in the Index name. The Index name here will be:  `human_resource1_name_id_idx`.

The Index will be created in the same keyspace where the original table is located.
Duplicate names are not allowed (as well as for custom Index names).

All other aspects (how it's visible, permissions, which keyspace used, duplicate index name, etc.) - were not affected by this commit.

Note: any spaces or non-printable symbols will be removed from the automatic Index name (for cases when column names have such symbols).

Test Plan: ybd --cxx-test ql-create-index-test

Reviewers: neil, robert, alex

Reviewed By: alex

Subscribers: kannan, eng

Differential Revision: https://phabricator.dev.yugabyte.com/D6378
@OlegLoginov
Copy link
Contributor

Fixed.

@yugabyte-ci yugabyte-ci added the community/request Issues created by external users label Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community/request Issues created by external users kind/enhancement This is an enhancement of an existing feature
Projects
None yet
Development

No branches or pull requests

4 participants