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

Support argument typing in (ad-hoc) queries #19

Open
benghippware opened this issue Mar 31, 2015 · 0 comments
Open

Support argument typing in (ad-hoc) queries #19

benghippware opened this issue Mar 31, 2015 · 0 comments

Comments

@benghippware
Copy link

Suppose I have a query like this:

SELECT COUNT(*) foo WHERE timestamp > ?

and a variable TimeStamp.

1/ If I execute this as a prepared query, and supply {0, TimeStamp, 0} as the argument, it works.

2/ If I execute this as an ad-hoc query, and supply Timestamp as the argument, seestar_cqltypes:encode_value_with_size() encodes it as a 32-bit integer.

This fails with a Cassandra error message "Expected 8 or 0 byte long for date (4)", presumably because it's expecting a 64-bit value because it's a timestamp column.

3/ If I execute this as an ad-hoc query and supply <<TimeStamp:64/signed>> as the argument, it works.

So now, here's my question ...

Whilst I can use method (3) to do what I want ... is it worth considering whether a better solution is to support providing argument typing for ad-hoc queries?

(It might also be useful for prepared queries as well.)

One possibility is ... Instead of supplying arguments as Timestamp, they could also be supplied as {timestamp, Timestamp} where the first element is the argument type.

Another possibility is to supply (optional) typing in the query string ie.

SELECT COUNT(*) foo WHERE timestamp > %t

where %t means a timestamp argument, %s means a string argument etc.

Do you think this is a good idea, maybe for the long-term?

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