Skip to content

Feature request: Support indexing expressions on columns #2250

@mtmacdonald

Description

@mtmacdonald

Follow-on ticket from #2206.

In my original ticket I submitted that this scenario did not parse:

Create a table (works)

CREATE TABLE IF NOT EXISTS items (
  id SERIAL PRIMARY KEY,
  title VARCHAR(100) NOT NULL,
  metadata JSON,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Adding an index (with LOWER() function) (fails)

CREATE UNIQUE INDEX IF NOT EXISTS idx_items_title_lower ON items(lower(title));

-> ERROR: at or near "(": syntax error

That was fixed in PR2227, but the fix only handled parsing the statement

Following this reply we agreed a new action: support indexing expressions on columns.

A larger issue than the parsing error is that Dolt and Doltgres cannot currently index expressions on columns, only the raw column values. So even if we parse this ALTER TABLE command successfully, we don't actually implement the semantics you're looking for here. We can add that feature but it's more involved than the simple parser fix Daylon implemented above. Can you please file a separate issue for that feature?

This one is only medium priority for me (I can probably progress testing doltgres in the meantime, thanks to the parsing fix).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions