Return-Path: X-Original-To: apmail-cassandra-user-archive@www.apache.org Delivered-To: apmail-cassandra-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2FBD211987 for ; Mon, 14 Jul 2014 07:46:02 +0000 (UTC) Received: (qmail 66548 invoked by uid 500); 14 Jul 2014 07:45:54 -0000 Delivered-To: apmail-cassandra-user-archive@cassandra.apache.org Received: (qmail 66510 invoked by uid 500); 14 Jul 2014 07:45:53 -0000 Mailing-List: contact user-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cassandra.apache.org Delivered-To: mailing list user@cassandra.apache.org Received: (qmail 66500 invoked by uid 99); 14 Jul 2014 07:45:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2014 07:45:53 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of doanduyhai@gmail.com designates 209.85.214.177 as permitted sender) Received: from [209.85.214.177] (HELO mail-ob0-f177.google.com) (209.85.214.177) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Jul 2014 07:45:50 +0000 Received: by mail-ob0-f177.google.com with SMTP id wp18so3624207obc.8 for ; Mon, 14 Jul 2014 00:45:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=dAeGO7LyqkvYhc5wMgUOH/rSVpFkr0jQKv9KuFBUYfM=; b=XnQ1HDvnWKJR+l3bV2AEAR4j4OLY95SGXsuibe0d9+kT4rmaQkVo6E0j4FZomMFzWi 6FQmURP3m+StqoJkdY//RqGgXIJCLSjikoqJ8Z4Fg/GJzFxcENjtSiQH6I0FudDYXh6M 3cofVSdKewyOFvhyVwhgxroLvnx2jT6L1dm+IVkRDfXUZCUh4Ij39kM/LBZAV7FT1r7p aX7zqfQRRA5SvCdLgcwvwN53hhCV9J/M4lFLsAdpoKK4FKmXQ3++0USpShIPt8cxCbJR 1l1/BPona2qpvVSF9u6k3EVIrKZUA7tnwmNPFF10jHQXB9zklmcwlG5OzcNucivo/kyd gatA== MIME-Version: 1.0 X-Received: by 10.182.28.66 with SMTP id z2mr15804427obg.19.1405323925930; Mon, 14 Jul 2014 00:45:25 -0700 (PDT) Received: by 10.76.2.45 with HTTP; Mon, 14 Jul 2014 00:45:25 -0700 (PDT) In-Reply-To: References: Date: Mon, 14 Jul 2014 09:45:25 +0200 Message-ID: Subject: Re: Multi-column range scans From: DuyHai Doan To: user@cassandra.apache.org Content-Type: multipart/alternative; boundary=089e0158b09e6647d804fe227975 X-Virus-Checked: Checked by ClamAV on apache.org --089e0158b09e6647d804fe227975 Content-Type: text/plain; charset=UTF-8 Hello Mathew Since Cassandra 2.0.6 it is possible to query over composites: https://issues.apache.org/jira/browse/CASSANDRA-4851 For your example: select * from skill_count where skill='Complaints' and (interval_id,skill_level) >= (1402359300000,5) and interval_id < 1402359900000; On Mon, Jul 14, 2014 at 6:09 AM, Matthew Allen wrote: > Hi, > > We have a roll-up table that as follows. > > CREATE TABLE SKILL_COUNT ( > skill text, > interval_id bigint, > skill_level int, > skill_count int, > PRIMARY KEY (skill, interval_id, skill_level)); > > Essentially, > skill = a names skill i.e. "Complaints" > interval_id = a rounded epoch time (15 minute intervals) > skill_level = a number/rating from 1-10 > skill_count = the number of people with the specified skill, with the > specified skill level, logged in at the interval_id > > We'd like to run the following query against it > > select * from skill_count where skill='Complaints' and interval_id >= > 1402359300000 and interval_id < 1402359900000 and skill_level >= 5; > > to get a count of people with the relevant skill and level at the > appropriate time. However I am getting the following message. > > Bad Request: PRIMARY KEY part skill_level cannot be restricted (preceding > part interval_id is either not restricted or by a non-EQ relation) > > Looking at how the data is stored ... > > ------------------- > RowKey: Complaints > => (name=1402359300000:2:, value=, timestamp=1405308260403000) > => (name=1402359300000:2:skill_count, value=0000000a, > timestamp=1405308260403000) > => (name=1402359300000:5:, value=, timestamp=1405308260403001) > => (name=1402359300000:5:skill_count, value=00000014, > timestamp=1405308260403001) > => (name=1402359300000:8:, value=, timestamp=1405308260419000) > => (name=1402359300000:8:skill_count, value=0000001e, > timestamp=1405308260419000) > => (name=1402359300000:10:, value=, timestamp=1405308260419001) > => (name=1402359300000:10:skill_count, value=00000001, > timestamp=1405308260419001) > > Should cassandra be able to allow for an extra level of filtering ? or is > this something that should be performed from within the application. > > We have a solution working in Oracle, but would like to store this data in > Cassandra, as all the other data that this solution relies on already sits > within Cassandra. > > Appreciate any guidance on this matter. > > Matt > --089e0158b09e6647d804fe227975 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello Mathew

=C2=A0Since Cassandra = 2.0.6 it is possible to query over composites: https://issues.apache.org/jira/browse/= CASSANDRA-4851

For your example:

select * from skill_count where skill= =3D'Complaints' and (interval_id,skill_level) >=3D (1402359300000,5) and interval_id < 1402359900000;


On Mon, Jul 14, 2014 at= 6:09 AM, Matthew Allen <matthew.j.allen@gmail.com> = wrote:
Hi,

We ha= ve a roll-up table that as follows.

CREATE TABLE SKILL_COUNT (<= br> =C2=A0 skill text,
=C2=A0 interval_id bigint,
=C2=A0 skill_level int,=
=C2=A0 skill_count int,
=C2=A0 PRIMARY KEY (skill, interval_id, skil= l_level));

Essentially,
=C2=A0 skill =3D a names skill i.= e. "Complaints"
=C2=A0 interval_id =3D a rounded ep= och time (15 minute intervals)
=C2=A0 skill_level =3D a numbe= r/rating from 1-10
=C2=A0 skill_count =3D the number of people with the specified s= kill, with the specified skill level, logged in at the interval_id

<= /div>
We'd like to run the following query against it

select= * from skill_count where skill=3D'Complaints' and interval_id >= =3D 1402359300000 and interval_id < 1402359900000 and skill_level >= =3D 5;

to get a count of people with the relevant skill and level a= t the appropriate time.=C2=A0 However I am getting the following message.
Bad Request: PRIMARY KEY part skill_level cannot be restricted (prece= ding part interval_id is either not restricted or by a non-EQ relation)

Looking at how the data is stored ...

----= ---------------
RowKey: Complaints
=3D> (name=3D1402359300000:2:, = value=3D, timestamp=3D1405308260403000)
=3D> (name=3D1402359300000:2:= skill_count, value=3D0000000a, timestamp=3D1405308260403000)
=3D> (name=3D1402359300000:5:, value=3D, timestamp=3D1405308260403001)=3D> (name=3D1402359300000:5:skill_count, value=3D00000014, timestamp= =3D1405308260403001)
=3D> (name=3D1402359300000:8:, value=3D, timesta= mp=3D1405308260419000)
=3D> (name=3D1402359300000:8:skill_count, value=3D0000001e, timestamp=3D= 1405308260419000)
=3D> (name=3D1402359300000:10:, value=3D, timestamp= =3D1405308260419001)
=3D> (name=3D1402359300000:10:skill_count, value= =3D00000001, timestamp=3D1405308260419001)

Should cassandra be able to allow for an extra level of filt= ering ? or is this something that should be performed from within the appli= cation.

We have a solution working in Oracle, but would like to stor= e this data in Cassandra, as all the other data that this solution relies o= n already sits within Cassandra.

Appreciate any guidance on this matter.

Ma= tt

--089e0158b09e6647d804fe227975--