You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Alexandre Gaudencio (JIRA)" <ji...@apache.org> on 2014/11/14 12:41:35 UTC
[jira] [Commented] (CASSANDRA-4210) Support for variadic parameters
list for "in clause" in prepared cql query
[ https://issues.apache.org/jira/browse/CASSANDRA-4210?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14212173#comment-14212173 ]
Alexandre Gaudencio commented on CASSANDRA-4210:
------------------------------------------------
I would like to add that using variadic params for IN has different effects depending on the prepare option.
I am using the nodejs driver.
With this query :
{code:javascript}
var query = 'SELECT * FROM event WHERE id IN (?)'
var params = [ '139a42b0-6bef-11e4-b6d6-0582c8632278,02203b20-6bef-11e4-a5a2-95978cb98ca6']
cql.execute(query, params, function (err, result) {
if (err) {
console.log(err)
} else {
console.log(result);
}
})
{code}
I get the result :
{code:none}
{ [ResponseError: UUID should be 16 or 0 bytes (369)]
name: 'ResponseError',
message: 'UUID should be 16 or 0 bytes (369)',
info: 'Represents an error message from the server',
code: 8704,
query: 'SELECT * FROM event WHERE id IN (?)' }
{code}
Whereas with a prepared statement, it goes like this :
{code:javascript}
var query = 'SELECT * FROM event WHERE id IN (?)'
var params = [ '139a42b0-6bef-11e4-b6d6-0582c8632278,02203b20-6bef-11e4-a5a2-95978cb98ca6']
cql.execute(query, params, { prepare : true } , function (err, result) {
if (err) {
console.log(err)
} else {
console.log(result);
}
})
{code}
{code:none}
{ rows:
[ { __columns: [Object],
id: '139a42b0-6bef-11e4-b6d6-0582c8632278',
name: someName,
type: 'someType',
value: '{"id":"someId"}' } ],
meta:
{ global_tables_spec: true,
keyspace: 'someKeyspace',
table: 'event',
columns:
[ [Object],
[Object],
[Object],
[Object],
_col_id: 0,
_col_name: 1,
_col_type: 2,
_col_value: 3 ] },
_queriedHost: 'xxx.xxx.xxx.xxx' }
{code}
The behavior is inconsistent.
In the first case I don't any result but an error instead stating that (as I understand it) the parser only excepted one UUID parameter and the received arg is too long.
In the second case, the query is ran without a problem except for the fact that only the first UUID is considered, the rest being ditched. And no error has been emitted. (This query should have returned two rows)
> Support for variadic parameters list for "in clause" in prepared cql query
> --------------------------------------------------------------------------
>
> Key: CASSANDRA-4210
> URL: https://issues.apache.org/jira/browse/CASSANDRA-4210
> Project: Cassandra
> Issue Type: Improvement
> Components: Core
> Affects Versions: 1.1.0
> Environment: prepared cql queries
> Reporter: Pierre Chalamet
> Assignee: Sylvain Lebresne
> Priority: Minor
> Fix For: 2.0.1
>
> Attachments: 4210.txt
>
>
> This query
> {code}
> select * from Town where key in (?)
> {code}
> only allows one parameter for '?'.
> This means querying for 'Paris' and 'London' can't be executed in one step with this prepared statement.
> Current workarounds are:
> * either execute the prepared query 2 times with 'Paris' then 'London'
> * or prepare a new query {{select * from Town where key in (?, ?)}} and bind the 2 parameters
> Having a support for variadic parameters list with in clause could improve performance:
> * single hop to get the data
> * // fetching server side
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)