fix #105. Panic when using a where clause that reference columns with null values

pull/113/merge
John Shahid 2013-12-05 16:15:16 -05:00
parent 594712aa8e
commit 7fa8c7fcfc
4 changed files with 55 additions and 0 deletions

View File

@ -155,6 +155,7 @@
- [Issue #90](https://github.com/influxdb/influxdb/issues/90). Group by multiple columns panic
- [Issue #89](https://github.com/influxdb/influxdb/issues/89). 'Group by' combined with 'where' not working
- [Issue #106](https://github.com/influxdb/influxdb/issues/106). Don't panic if we only see one point and can't calculate derivative
- [Issue #105](https://github.com/influxdb/influxdb/issues/105). Panic when using a where clause that reference columns with null values
### Deprecated

View File

@ -14,7 +14,34 @@ const (
TYPE_UNKNOWN
)
func getValue(value *protocol.FieldValue) (interface{}, Type) {
if value.Int64Value != nil {
return value.Int64Value, TYPE_INT
}
if value.DoubleValue != nil {
return value.DoubleValue, TYPE_DOUBLE
}
if value.BoolValue != nil {
return value.BoolValue, TYPE_BOOL
}
if value.StringValue != nil {
return value.StringValue, TYPE_STRING
}
return nil, TYPE_UNKNOWN
}
func CoerceValues(leftValue, rightValue *protocol.FieldValue) (interface{}, interface{}, Type) {
if leftValue == nil {
value, t := getValue(rightValue)
return nil, value, t
}
if rightValue == nil {
value, t := getValue(leftValue)
return value, nil, t
}
if leftValue.Int64Value != nil {
if rightValue.Int64Value != nil {
return *leftValue.Int64Value, *rightValue.Int64Value, TYPE_INT

View File

@ -16,6 +16,10 @@ func wrapOldBooleanOperation(operation oldBooleanOperation) BooleanOperation {
return false, fmt.Errorf("Expected one value on the right side")
}
if leftValue == nil || rightValues[0] == nil {
return false, nil
}
return operation(leftValue, rightValues[0])
}
}

View File

@ -614,6 +614,29 @@ func (self *IntegrationSuite) TestIssue106(c *C) {
c.Assert(data[0].Points, HasLen, 0)
}
func (self *IntegrationSuite) TestIssue105(c *C) {
err := self.server.WriteData(`
[
{
"name": "test_issue_105",
"columns": ["time", "a", "b"],
"points":[
[1386262529794, 2, 1],
[1386262529794, 2, null]
]
}
]`, "time_precision=m")
c.Assert(err, IsNil)
bs, err := self.server.RunQuery("select a, b from test_issue_105 where b > 0")
c.Assert(err, IsNil)
data := []*h.SerializedSeries{}
err = json.Unmarshal(bs, &data)
c.Assert(data, HasLen, 1)
c.Assert(data[0].Columns, HasLen, 4)
c.Assert(data[0].Points, HasLen, 1)
c.Assert(data[0].Points[0][3], Equals, 1.0)
}
// test for issue #41
func (self *IntegrationSuite) TestDbDelete(c *C) {
err := self.server.WriteData(`