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

Feature Request: Enforce query size limit #51

Closed
lordnynex opened this issue Mar 29, 2015 · 8 comments
Closed

Feature Request: Enforce query size limit #51

lordnynex opened this issue Mar 29, 2015 · 8 comments

Comments

@lordnynex
Copy link
Contributor

It seems cassandra has some sort of max query size?

I'm performing a very large WHERE IN () and it appears the query is being truncated consistently which throws a syntax error.

Cassandra returned error (Syntax_error): "line 1:6116 no viable alternative at input ')' (...

I'm not sure what this limit is but it would be nice if the driver knew about it.

@jbochi
Copy link
Owner

jbochi commented Mar 30, 2015

Hi Brandon,

The frame is limited by the protocol in 256MB. Is it possible that you are
hitting this limit? How many elements and of which type are you using in
the WHERE IN clause?

@lordnynex
Copy link
Contributor Author

I believe this is a malformed query on my side. In the end the fix was to break the WHERE IN clause into multiple select's. I wish I had more time to chase this down, but the IN clause was around 1000 arguments.

I was thinking, it would be beneficial to my current and future work if I can pass a tailored object to bind params on select. Similar to :execute("INSERT INTO ...(some_set) VALUES(?)", { cassandra.set){}).

@jbochi
Copy link
Owner

jbochi commented Mar 30, 2015

Sorry, I am not sure I understood your suggestion correctly. Do you mean named arguments like #28?

Could you please elaborate?

Anyway, I will close this issue for now. Please feel free to open it again if you are able to reproduce the issue.

@jbochi jbochi closed this as completed Mar 30, 2015
@lordnynex
Copy link
Contributor Author

I want to use bind params on a large WHERE IN SET. As opposed to writing 'WHERE IN(?, ?, ?, ?, ?........)

I'd like to write something like
c:execute("SELECT id FROM table WHERE id IN(?)", { cassandra.whereIn({ flat table of values}))

@thibaultcha
Copy link
Contributor

You can already do this @lordnynex. A IN is a cassandra.list iirc.

So you can have

c:execute("SELECT id FROM table WHERE id IN ?", { cassandra.list({"foo", "bar"}))

@lordnynex
Copy link
Contributor Author

Oh awesome. I'll give it a shot. I was under the impression that cassandra.list was the equivalent of { '', '' } which seemed in-congruent with the where in syntax.

@thibaultcha
Copy link
Contributor

If not, give a try to one of the other types. I am 100% sure this is possible because I did it in the past, don't remember which type/syntax combination tho.

@jbochi
Copy link
Owner

jbochi commented Mar 31, 2015

@lordnynex, @thibaultcha is right, you can use cassandra.list for that. There is an example in the specs: https://github.com/jbochi/lua-resty-cassandra/blob/master/spec/functional_spec.lua#L170

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