diff --git a/engine/filtering_helpers.go b/engine/filtering_helpers.go index 93e472fc39a..1692b918f5a 100644 --- a/engine/filtering_helpers.go +++ b/engine/filtering_helpers.go @@ -14,12 +14,17 @@ func getExpressionValue(values []*parser.Value, fields []string, point *protocol switch value.Type { case parser.ValueFunctionCall: return nil, fmt.Errorf("Cannot process function call %s in expression", value.Name) + case parser.ValueInt: + value, err := strconv.ParseInt(value.Name, 10, 64) + if err == nil { + fieldValues = append(fieldValues, &protocol.FieldValue{Int64Value: &value}) + continue + } + // an error will happen only if the integer is out of range + fallthrough case parser.ValueFloat: value, _ := strconv.ParseFloat(value.Name, 64) fieldValues = append(fieldValues, &protocol.FieldValue{DoubleValue: &value}) - case parser.ValueInt: - value, _ := strconv.ParseInt(value.Name, 10, 64) - fieldValues = append(fieldValues, &protocol.FieldValue{Int64Value: &value}) case parser.ValueBool: value, _ := strconv.ParseBool(value.Name) fieldValues = append(fieldValues, &protocol.FieldValue{BoolValue: &value}) diff --git a/integration/data_test.go b/integration/data_test.go index e980132744a..0c44eb47f07 100644 --- a/integration/data_test.go +++ b/integration/data_test.go @@ -168,6 +168,36 @@ func (self *DataTestSuite) TestFillingEntireRange(c *C) { } } +func (self *DataTestSuite) TestBigInts(c *C) { + data := ` +[ + { + "name": "test_mode", + "columns": ["value"], + "points": [ + [7335093126128605887], + [15028546720250474530] + ] + } + ]` + self.client.WriteJsonData(data, c, influxdb.Millisecond) + for _, i := range []uint64{7335093126128605887, 15028546720250474530} { + q := fmt.Sprintf("select count(value) from test_mode where value = %d", i) + serieses := self.client.RunQuery(q, c, "m") + c.Assert(serieses, HasLen, 1) + maps := ToMap(serieses[0]) + c.Assert(maps, HasLen, 1) + c.Assert(maps[0]["count"], Equals, 1.0) + } + + q := "select count(value) from test_mode where value >= 15028546720250474530 and value <= 15028546720250474530" + serieses := self.client.RunQuery(q, c, "m") + c.Assert(serieses, HasLen, 1) + maps := ToMap(serieses[0]) + c.Assert(maps, HasLen, 1) + c.Assert(maps[0]["count"], Equals, 1.0) +} + func (self *DataTestSuite) TestModeWithInt(c *C) { data := ` [