Cassandra::getWhere causes cassandra_InvalidRequestException #10

Mark-K opened this Issue Dec 6, 2011 · 4 comments

2 participants


A cassandra_InvalidRequestException occurs in Cassandra::getWhere() when using where array format #2.
Cassandra-PHP-Client-Library (2011-12-04)
PHP 5.3.8

(I'm new to both PHP and Cassandra and so could be overlooking something obvious.)

Except from Cassandra.php:
* The where array can be a mix of two formats:
* 1. For simplest equality comparison - column value must equal something
* exactly, the format array('column-name' => 'required value') can be
* used.
* 2. For any other supported comparison operators, use the slightly longer
* syntax array(array('column-name', Cassandra::OP_LT, 'value')) where
* each component is an array with three values, the first one being the
* column name, second comparison operator and third the value. Use the
* Cassandra::OP_.. constants for operators.
* You can mix the two variants.

Added to example.php (at line 193):
$aged24andOlder = $cassandra->cf('user')->getWhere(
array(array('age', Cassandra::OP_GTE, 24))
echo 'Users aged 24+:

'.print_r($aged24andOlder->getAll(), true).'


Fatal error: Uncaught exception 'cassandra_InvalidRequestException' in /usr/local/php/lib/php/Cassandra/thrift/packages/cassandra/Cassandra.php:4286
Stack trace:

0 /usr/local/php/lib/php/Cassandra/thrift/packages/cassandra/Cassandra.php(587): cassandra_Cassandra_get_indexed_slices_result->read(Object(TBinaryProtocolAccelerated))

1 /usr/local/php/lib/php/Cassandra/thrift/packages/cassandra/Cassandra.php(545): cassandra_CassandraClient->recv_get_indexed_slices()

2 [internal function]: cassandra_CassandraClient->get_indexed_slices(Object(cassandra_ColumnParent), Object(cassandra_IndexClause), Object(cassandra_SlicePredicate), 1)

3 /usr/local/php/lib/php/Cassandra/Cassandra.php(968): call_user_func_array(Array, Array)

4 /usr/local/php/lib/php/Cassandra/Cassandra.php(3621): Cassandra->call('get_indexed_sli...', Object(cassandra_ColumnParent), Object(cassandra_IndexClause), Object(cassandra_SlicePredicate), 1)

5 /usr/local/php/lib/ph in /usr/local/php/lib/php/Cassandra/Cassandra.php on line 976


After testing other operators, Cassandra::OP_EQ is the only operator that does not throw an exception.


I believe you can only use the other comparisor operators, you need to have an index set up, see the unit tests file to see how it's done. Also note that when using range queries, you need to use order preserving partitioner. Let me know if that does not work for you.

@kallaspriit kallaspriit closed this Dec 6, 2011

The Pear package PHPUnit has been installed; but, the test case does not work.

$ php ./CassandraTest.php

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /opt/air/wise_sync_prototype/php/lib/php/Cassandra/test/CassandraTest.php on line 5


This works...

$phpunit CassandraTest.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment