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

count(*) always returns 0 if table has a vector index #76

Open
andreaswimmer opened this issue Nov 14, 2024 · 0 comments
Open

count(*) always returns 0 if table has a vector index #76

andreaswimmer opened this issue Nov 14, 2024 · 0 comments

Comments

@andreaswimmer
Copy link

import random

import libsql_experimental as libsql

conn = libsql.connect(":memory:")
dims = 4
conn.execute(f"""
    CREATE TABLE vectors
    (
        vector_id INTEGER PRIMARY KEY,
        vector F32_BLOB({dims})
    ) 
    """)
conn.execute("CREATE INDEX vector_idx ON vectors(libsql_vector_idx(vector))")
data = []
for primary in range(10):
    vector = ','.join(str(random.random()) for _ in range(dims))
    data.append((primary, f"[{vector}]"))

conn.executemany("""
INSERT INTO vectors
values (?, ?)
""", data)
print(conn.execute("SELECT COUNT(*) FROM vectors").fetchall())
print(conn.execute("SELECT * FROM vectors").fetchall())

In this program, count(*) returns 0, even though the table has 10 rows.
If you comment out the 'CREATE INDEX' line, the correct answer of 10 is given.

Using libsql-experimental 0.0.41

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