Another approach is, instead of using $$, you can put additional pair of
single quote around the 'Minneapolis, MN'

cqlsh> insert into system_distributed.partition_denylist (ks_name,
table_name, key) values ('stackoverflow', 'weather_sensor_data',
textAsBlob('''Minneapolis, MN'', 202210'));

cqlsh> select ks_name, table_name, blobAsText(key) from
system_distributed.partition_denylist;

 ks_name       | table_name          | system.blobastext(key)

---------------+---------------------+---------------------------

 stackoverflow | weather_sensor_data | 'Minneapolis, MN', 202210

On Mon, Oct 17, 2022 at 2:30 PM Cheng Wang <che...@netflix.com> wrote:

> Hi Aaron,
>
> Yes, you can directly insert into the system_distributed.partition_denylist
> instead of using JMX. Jordan wrote a blog post for denylist
>
> https://cassandra.apache.org/_/blog/Apache-Cassandra-4.1-Denylisting-Partitions.html
>
> And the syntax error, one way around is to put $$ around like below
>
> cqlsh> insert into system_distributed.partition_denylist (ks_name,
> table_name, key) values ('stackoverflow', 'weather_sensor_data',
> textAsBlob($$'Minneapolis, MN', 202210$$));
>
> There is post about this
>
> https://docs.datastax.com/en/cql-oss/3.3/cql/cql_reference/escape_char_r.html#:~:text=Column%20names%20that%20contain%20characters,using%20a%20single%20quotation%20mark
> .
>
> and then you can verify the insert by doing
>
> cqlsh> select ks_name, table_name, blobAsText(key) from
> system_distributed.partition_denylist;
>
>  ks_name       | table_name          | system.blobastext(key)
>
> ---------------+---------------------+---------------------------
>
>  stackoverflow | weather_sensor_data | 'Minneapolis, MN', 202210
> Pls let me know if it works for you.
>
>
> On Mon, Oct 17, 2022 at 1:35 PM Aaron Ploetz <aaronplo...@gmail.com>
> wrote:
>
>> I have this table definition:
>>
>> CREATE TABLE stackoverflow.weather_sensor_data (
>>     city text,
>>     month int,
>>     recorded_time timestamp,
>>     temp float,
>>     PRIMARY KEY ((city, month), recorded_time)
>> ) WITH CLUSTERING ORDER BY (recorded_time DESC)
>>
>> Sample data looks like this:
>>
>> > SELECT * FROM weather_sensor_data WHERE city='Minneapolis, MN' AND
>> month=202111;
>>
>>  city            | month  | recorded_time                   | temp
>> -----------------+--------+---------------------------------+------
>>  Minneapolis, MN | 202111 | 2021-11-01 08:35:00.000000+0000 |    3
>>  Minneapolis, MN | 202111 | 2021-11-01 08:30:00.000000+0000 |    3
>>  Minneapolis, MN | 202111 | 2021-11-01 08:25:00.000000+0000 |    2
>>  Minneapolis, MN | 202111 | 2021-11-01 08:20:00.000000+0000 |    2
>>  Minneapolis, MN | 202111 | 2021-11-01 08:15:00.000000+0000 |    2
>>
>> (5 rows)
>>
>> Using JMX Term, I've tried to denylist that partition, but I must have
>> the syntax for composite keys incorrect:
>>
>> $>bean org.apache.cassandra.db:type=StorageProxy
>> $>run denylistKey stackoverflow weather_sensor_data "'Minneapolis,
>> MN',202210"
>> #IllegalArgumentException: Operation denylistKey with 4 parameters
>> doesn't exist in bean org.apache.cassandra.db:type=StorageProxy
>>
>> Obviously, it's reading the space between "Minneapolis," and "MN" as a
>> delimiter.  What's the right way to handle commas, spaces, and composite
>> keys for this?
>>
>> Also, is there another way to accomplish this without using JMX?
>>
>> Thanks,
>>
>> Aaron
>>
>>
>>
>>

Reply via email to