Return an error if an invalid column is used to filter after a join

Fix #652
pull/991/head
John Shahid 2014-09-04 12:34:04 -04:00
parent 9b9ac93652
commit 42bef2508c
2 changed files with 30 additions and 1 deletions

View File

@ -52,7 +52,10 @@ func getJoinYield(query *parser.SelectQuery, yield func(*protocol.Series) error)
lastPoint1 = nil
lastPoint2 = nil
filteredSeries, _ := Filter(query, newSeries)
filteredSeries, err := Filter(query, newSeries)
if err != nil {
return err
}
if len(filteredSeries.Points) > 0 {
return yield(newSeries)
}

View File

@ -570,6 +570,32 @@ func (self *DataTestSuite) JoinAndArithmetic(c *C) (Fun, Fun) {
}
}
// issue #652
func (self *DataTestSuite) JoinWithInvalidFilteringShouldReturnMeaningfulError(c *C) (Fun, Fun) {
return func(client Client) {
t1 := time.Now().Truncate(time.Hour).Add(-4 * time.Hour)
t2 := t1.Add(time.Hour)
t3 := t2.Add(time.Hour)
t4 := t3.Add(time.Hour)
data := fmt.Sprintf(`[
{
"name":"foo",
"columns":["time", "val"],
"points":[[%d, 1],[%d, 2]]
},
{
"name":"bar",
"columns":["time", "val"],
"points":[[%d, 3],[%d, 4]]
}]`, t1.Unix(), t3.Unix(), t2.Unix(), t4.Unix())
client.WriteJsonData(data, c, "s")
}, func(client Client) {
s := client.RunQuery("select foo.val + bar.val from foo inner join bar where val <> 3", c, "m")
c.Assert(s, HasLen, 0)
}
}
// issue #540
func (self *DataTestSuite) RegexMatching(c *C) (Fun, Fun) {
return func(client Client) {