Skip to content
This repository has been archived by the owner. It is now read-only.

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

Merged
merged 1 commit into from Aug 10, 2017

Conversation

Projects
None yet
4 participants
@c-w
Copy link
Member

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 Jul 28, 2017

@jcjimenez
Copy link
Contributor

left a comment

LGTM

@c-w c-w force-pushed the non-eq-queries branch from 46cf487 to aeac106 Jul 28, 2017

@Smarker
Copy link
Contributor

left a comment

LGTM

@erikschlegel
Copy link
Contributor

left a comment

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

@c-w

This comment has been minimized.

Copy link
Member Author

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 Aug 3, 2017

@erikschlegel
Copy link
Contributor

left a comment

LGTM

Move all non-equals query columns to end of key
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 force-pushed the non-eq-queries branch from 3c50445 to 39ff790 Aug 10, 2017

@c-w c-w merged commit 68b3d5d into master Aug 10, 2017

0 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details

@c-w c-w deleted the non-eq-queries branch Aug 10, 2017

rachelnicole pushed a commit that referenced this pull request Jan 24, 2018

rachelnicole pushed a commit that referenced this pull request Jan 24, 2018

Merge pull request #93 from CatalystCode/facebookexternalsources-disp…
…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.
You can’t perform that action at this time.