Skip to content

Commit

Permalink
Return an error if an invalid column is used to filter after a join
Browse files Browse the repository at this point in the history
Fix #652
  • Loading branch information
jvshahid committed Sep 24, 2014
1 parent 9b9ac93 commit 42bef25
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion engine/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
26 changes: 26 additions & 0 deletions integration/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 42bef25

Please sign in to comment.