Cassandra:[无效的查询] message =“PRIMARY KEY column”lng“不能被限制 [英] Cassandra :[Invalid query] message="PRIMARY KEY column "lng" cannot be restricted
问题描述
在cqlsh中执行以下查询时遇到错误
查询
SELECT * FROM ragchews.disc_location WHERE country_code = 12 AND lat> 100.00和lat < 120.00和lng> 50和100允许过滤;
CREATE TABLE ragchews.disc_location(
country_code int,
lat float,
lng float,
uid text,
PRIMARY KEY(country_code,lat,lng,uid)
);
错误:
code = 2200 [无效的查询] message =PRIMARY KEY列lng不能限制(前面的列ColumnDefinition {name = lat,type = org.apache.cassandra.db .marshal.FloatType,kind = CLUSTERING_COLUMN,componentIndex = 0,indexName = null,indexType = null}不受限制或通过非EQ关系)
Cassandra版本
[cqlsh 5.0 .1 | Cassandra 2.1.2 | CQL spec 3.2.0 |本机协议v3]
编辑1
以下查询适用于我
SELECT * FROM ragchews.disc_location WHERE country_code = 91,lat> 32和lat < 100允许过滤;
这看起来像 lng
。
您不能有此类查询。您可以添加>或<
作为您的where子句聚簇键的最后一部分,为前面的键提供 =
。例如,以下查询将正常工作,
SELECT * FROM ragchews.disc_location WHERE country_code = 12 AND lat = 100.00 and lng> ; 50和100;
或甚至以下工作,
SELECT * FROM ragchews.disc_location WHERE country_code = 12 AND lat = 100.00 and lng = 50 and uid> '500'和uid < '1000'
但是两个where子句具有或者,条件
将无法工作。
I am getting an error while executing following query in cqlsh
Query
SELECT * FROM ragchews.disc_location WHERE country_code = 12 AND lat > 100.00 and lat < 120.00 and lng > 50 and lng < 100 allow filtering;
Table
CREATE TABLE ragchews.disc_location (
country_code int,
lat float,
lng float,
uid text,
PRIMARY KEY (country_code, lat, lng, uid)
);
Error:
code=2200 [Invalid query] message="PRIMARY KEY column "lng" cannot be restricted (preceding column "ColumnDefinition{name=lat, type=org.apache.cassandra.db.marshal.FloatType, kind=CLUSTERING_COLUMN, componentIndex=0, indexName=null, indexType=null}" is either not restricted or by a non-EQ relation)"
Cassandra version
[cqlsh 5.0.1 | Cassandra 2.1.2 | CQL spec 3.2.0 | Native protocol v3]
Edit 1
Following query works fine for me
SELECT * FROM ragchews.disc_location WHERE country_code=91 and lat > 32 and lat < 100 allow filtering;
That looks like something is wrong with column lng
.
You cannot have such query. You can add > or <
for your last part of your where clause clustering key, provided =
for the preceding keys. For example the following query will work fine,
SELECT * FROM ragchews.disc_location WHERE country_code = 12 AND lat = 100.00 and lng > 50 and lng < 100;
or even the following will work,
SELECT * FROM ragchews.disc_location WHERE country_code = 12 AND lat = 100.00 and lng = 50 and uid > '500' and uid < '1000'
But two where clause having > or < condition
will wont work.
这篇关于Cassandra:[无效的查询] message =“PRIMARY KEY column”lng“不能被限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!