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

Python Prepared Statement Parameters #3135

Closed
mxwli opened this issue Mar 25, 2024 · 1 comment
Closed

Python Prepared Statement Parameters #3135

mxwli opened this issue Mar 25, 2024 · 1 comment
Assignees

Comments

@mxwli
Copy link
Collaborator

mxwli commented Mar 25, 2024

Currently, we treat python parameters to be as wide as they can reasonably get. All integer types are treated as INT64, all float types are treated as DOUBLE. However, consider the following script

import kuzu
db = kuzu.Database("tmpdatabase")
conn = kuzu.Connection(db)
conn.execute("CREATE NODE TABLE t1(id SERIAL, number INT32, PRIMARY KEY(id))")
conn.execute("CREATE (:t1 {number: $1})", {"1": 2})

You would expect for the node to be created; but it isn't. We get the following error

RuntimeError: Parameter 1 has data type INT64 but expects INT32

This is because the way we resolve the type of python parameters right now assigns all integers to INT64 (and all floats to DOUBLE)

What if we implemented a technique that found the narrowest type of our parameters? You can't always make a 64 bit integer into a 32 bit integer, but you can always make a smaller width integer into a larger width integer. I tried it out in the #3090 PR, but it turns out that it doesn't work either.

RuntimeError: Parameter 1 has data type INT8 but expects INT32

The way we expect the type of prepared statement parameters doesn't allow for implicit casting like this.

If we ship the code that does this in #3090 in a release, we must ship corresponding changes that additionally allow for the implicit casting of parameters. This is not ideal, since then it would take a really long time to resolve #3054.

My proposal is that we limit the scope of #3090 to just LIST and MAP parameters, and resolve the above problems in a future set of PRs.

@andyfengHKU
Copy link
Contributor

Fixed in #3374

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

3 participants