Cyrus
Cyrus

Reputation: 1022

Using a sub-string of the column name in creating index in CockroachDB

Moving from Oracle to CockroachDB, I'm using a index creating command as below:

CREATE INDEX ON "sales" (substring("a",0,19), substring("b",20,2), "c");

The error I get is:

invalid syntax: statement ignored: unimplemented at or near ")"
CREATE INDEX ON "sales" (substring("a",0,19), substring("b",20,2), "c");

I have also used: substr

but the error is the same.

--

Edit1: The error for the modified command

CREATE INDEX ON "sales" (substring("a",0,19));

will be the same.

Upvotes: 1

Views: 394

Answers (2)

Sergio Fonseca
Sergio Fonseca

Reputation: 356

Cockroach-DB Create INDEX Sypnosis.

According to the automata that validates the string to create an index in a table, there is no possibility to make use of the substring function.

Upvotes: 0

Jordan Lewis
Jordan Lewis

Reputation: 17938

You're trying to use a computed index - an index with keys that are more complex than column references. CockroachDB doesn't support computed indexes yet.

There's an open issue for adding support for computed indexes:

https://github.com/cockroachdb/cockroach/issues/9682

Upvotes: 1

Related Questions