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

"CREATE INDEX IF NOT EXISTS" doesn't work #119

Open
2 tasks done
yyuu opened this issue Oct 11, 2024 · 0 comments
Open
2 tasks done

"CREATE INDEX IF NOT EXISTS" doesn't work #119

yyuu opened this issue Oct 11, 2024 · 0 comments

Comments

@yyuu
Copy link

yyuu commented Oct 11, 2024

What happens?

DuckDB accepts CREATE INDEX statement with IF NOT EXISTS, however, it seems IF NOT EXISTS isn't actually working with SQLite3 tables.

To Reproduce

If I were invoke CREATE INDEX IF NOT EXISTS for the first time, it creates index on the table.

% rm -f foo.sqlite
% duckdb -c "ATTACH 'foo.sqlite' AS foo (TYPE SQLITE); USE foo; CREATE TABLE IF NOT EXISTS t1 (key VARCHAR, value VARCHAR); CREATE INDEX IF NOT EXISTS t1_key ON t1 (key);"
% sqlite3 foo.sqlite .schema
-- Loading resources from /Users/yyuu/.sqliterc
CREATE TABLE t1("key" VARCHAR, "value" VARCHAR);
CREATE INDEX t1_key ON t1("key");
CREATE TABLE temp.sqlite_parameters(
  key TEXT PRIMARY KEY,
  value
) WITHOUT ROWID;

Although if I were invoking identical CREATE INDEX IF NOT EXISTS again, it fails.

% duckdb -c "ATTACH 'foo.sqlite' AS foo (TYPE SQLITE); USE foo; CREATE TABLE IF NOT EXISTS t1 (key VARCHAR, value VARCHAR); CREATE INDEX IF NOT EXISTS t1_key ON t1 (key);"
Invalid Error: Failed to execute query "CREATE INDEX t1_key ON t1("key")": index t1_key already exists

OS:

macOS

SQLite Version:

3.43.2 2023-10-10 13:08:14 1b37c146ee9ebb7acd0160c0ab1fd11017a419fa8a3187386ed8cb32b709aapl (64-bit)

DuckDB Version:

v1.1.1 af39bd0dcf

DuckDB Client:

CLI

Full Name:

Yuu Yamashita

Affiliation:

Treasure Data, Inc.

Have you tried this on the latest main branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant