Ignore shards that don't have the selected measurement in them.

Fixes #2815 and fixes #2818.
pull/2820/head
Paul Dix 2015-06-08 17:14:42 +02:00
parent eaec3e42e4
commit 8f712eaf85
2 changed files with 10 additions and 3 deletions

View File

@ -466,9 +466,9 @@ func TestServer_Query_Multiple_Measurements(t *testing.T) {
test.addQueries([]*Query{
&Query{
name: "tag without field should return error",
name: "measurement in one shard but not another shouldn't panic server",
command: `SELECT host,value FROM db0.rp0.cpu`,
exp: `{"results":[{"error":"select statement must include at least one field or function call"}]}`,
exp: `{"results":[{"series":[{"name":"cpu","tags":{"host":"server01"},"columns":["time","value"],"values":[["2000-01-01T00:00:00Z",100]]}]}]}`,
},
}...)

View File

@ -169,13 +169,20 @@ func (tx *tx) CreateMapReduceJobs(stmt *influxql.SelectStatement, tagKeys []stri
continue
}
// get the codec for this measuremnt. If this is nil it just means this measurement was
// never written into this shard, so we can skip it and continue.
codec := shard.FieldCodec(m.Name)
if codec == nil {
continue
}
var mapper influxql.Mapper
mapper = &LocalMapper{
seriesKeys: t.SeriesKeys,
db: shard.DB(),
job: job,
decoder: shard.FieldCodec(m.Name),
decoder: codec,
filters: t.Filters,
whereFields: whereFields,
selectFields: selectFields,