Skip to content
This repository was archived by the owner on Mar 7, 2018. It is now read-only.

Move all non-equals query columns to end of key#93

Merged
c-w merged 1 commit intomasterfrom
non-eq-queries
Aug 10, 2017
Merged

Move all non-equals query columns to end of key#93
c-w merged 1 commit intomasterfrom
non-eq-queries

Conversation

@c-w
Copy link
Contributor

@c-w c-w commented Jul 28, 2017

If we want to query some columns in a cluster key by an equals relationship (e.g. externalsourceid = 'aljazeera') and others by a non-equals relationship (e.g. (tilex, tiley) <= (1, 1)) then all the equals columns have to come before all the non-equals columns, otherwise we get an error like this:

InvalidRequest: Error from server: code=2200 [Invalid query]
message="PRIMARY KEY column "pipelinekey" cannot be restric
ted (preceding column "tilex" is restricted by a non-EQ relation)"

@c-w c-w requested a review from erikschlegel July 28, 2017 21:55
Copy link
Contributor

@jcjimenez jcjimenez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@c-w c-w force-pushed the non-eq-queries branch from 46cf487 to aeac106 Compare July 28, 2017 21:58
Copy link
Contributor

@Smarker Smarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@erikschlegel erikschlegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the motivation behind re-arranging the PKs for pipelinekey, externalsourceid?

@c-w
Copy link
Contributor Author

c-w commented Aug 3, 2017

@erikschlegel This PR is essentially just moving all the keys on which we do a range query (like <= or >=) to the end of the key definition. Any key for which we do a point query (i.e., =) has to come before the range queries for Cassandra to accept the query.

For example, this will not work:

CREATE TABLE foo (
  col1 text,
  col2 text,
  col3 int,
  col4 int,
  PRIMARY KEY ((col1), col3, col4, col2)
);

SELECT *
FROM foo
WHERE col1='a'
  AND col2='b'
  AND (col3, col4) <= (10, 10)
  AND (col3, col4) >= (0, 0);

However, the query would work with this table definition since all the point query columns (col1 and col2) come before all the range query columns (col3 and `col4) in the key definition:

CREATE TABLE foo (
  col1 text,
  col2 text,
  col3 int,
  col4 int,
  PRIMARY KEY ((col1), col2, col3, col4)
);

So the motivating for moving the pipelinekey and externalsourceid is to put them before columns like tilex or tiley so that we can range query on the latter while point querying on the former.

@c-w c-w force-pushed the non-eq-queries branch from aeac106 to 3c50445 Compare August 3, 2017 23:06
Copy link
Contributor

@erikschlegel erikschlegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

If we want to query some columns in a cluster key by an equals
relationship (e.g. `externalsourceid = 'aljazeera'`) and others by a
non-equals relationship (e.g. `(tilex, tiley) <= (1, 1)`) then all the
equals columns have to come before all the non-equals columns, otherwise
we get an error like this:

```
InvalidRequest: Error from server: code=2200 [Invalid query]
message="PRIMARY KEY column "pipelinekey" cannot be restric
ted (preceding column "tilex" is restricted by a non-EQ relation)"
```
@c-w c-w merged commit 68b3d5d into master Aug 10, 2017
@c-w c-w deleted the non-eq-queries branch August 10, 2017 18:00
rachelnicole pushed a commit that referenced this pull request Jan 24, 2018
rachelnicole pushed a commit that referenced this pull request Jan 24, 2018
…layname

Display pretty name for sources if available
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants