2
votes

Trying to query a Cassandra 1.2 table for a column with empty strings, I am getting an error:

cql.apivalues.ProgrammingError: Bad Request: Key may not be empty


Context:

The CQL statement being sent uses a cursor and is intended to get all rows where the first_name column has an empty string. The cql_query text sent to the cursor is:

SELECT obj_key 
     FROM person_first_name_last_name
     WHERE first_name = :first_name_0 AND last_name = :last_name_1
     LIMIT 50

with params:

{'first_name_0': '', 'last_name_1': 'd'}


As far as I understand, this should be possible. However, this error seems to indicate that an empty string is not a valid search value. What can I do to resolve this?

Thanks very much!

1

1 Answers

1
votes

As far as I know you can't have a null column value when that column is the key or it is part of a composite key (at least not in CQL).

The workaround is to set the column to a non-existing value in your data, in your example using 'zx123' should be enough, since nobody has zx123 as a first name or last name. Using a simple blank (space) should work too of course.