fix #437. Queries with negative constants don't parse properly
parent
8d810e8807
commit
6cb941310e
|
@ -7,6 +7,7 @@
|
|||
- [Issue #442](https://github.com/influxdb/influxdb/issues/442). shouldQuerySequentially didn't work as expected
|
||||
causing count(*) queries on large time series to use
|
||||
lots of memory
|
||||
- [Issue #437](https://github.com/influxdb/influxdb/issues/437). Queries with negative constants don't parse properly
|
||||
|
||||
## v0.5.6 [2014-04-08]
|
||||
|
||||
|
|
|
@ -1073,6 +1073,25 @@ func (self *DataTestSuite) ArithmeticOperations(c *C) (Fun, Fun) {
|
|||
}
|
||||
}
|
||||
|
||||
// issue #437
|
||||
func (self *DataTestSuite) ConstantsInArithmeticQueries(c *C) (Fun, Fun) {
|
||||
return func(client Client) {
|
||||
data := `[{"points": [[1]], "name": "test_constants", "columns": ["value"]}]`
|
||||
client.WriteJsonData(data, c)
|
||||
}, func(client Client) {
|
||||
for _, query := range []string{
|
||||
"select -1 * value from test_constants",
|
||||
"select -1.0 * value from test_constants",
|
||||
} {
|
||||
collection := client.RunQuery(query, c)
|
||||
c.Assert(collection, HasLen, 1)
|
||||
maps := ToMap(collection[0])
|
||||
c.Assert(maps, HasLen, 1)
|
||||
c.Assert(maps[0]["expr0"], Equals, -1.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (self *DataTestSuite) CountQueryOnSingleShard(c *C) (Fun, Fun) {
|
||||
return func(client Client) {
|
||||
data := `[{"points": [[4], [10], [5]], "name": "test_count_query_single_shard", "columns": ["value"]}]`
|
||||
|
|
|
@ -699,6 +699,13 @@ func (self *QueryParserSuite) TestParseSelectWithRegexCondition(c *C) {
|
|||
c.Assert(expr.Name, Equals, "gmail\\.com")
|
||||
}
|
||||
|
||||
func (self *QueryParserSuite) TestQueryWithArithmeticColumns(c *C) {
|
||||
q, err := ParseSelectQuery("select -1 * value from cpu.idle")
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(q.ColumnNames, HasLen, 1)
|
||||
c.Assert(int(q.ColumnNames[0].Type), Equals, ValueExpression)
|
||||
}
|
||||
|
||||
func (self *QueryParserSuite) TestParseSelectWithComplexArithmeticOperations(c *C) {
|
||||
q, err := ParseSelectQuery("select value from cpu.idle where .30 < value * 1 / 3 ;")
|
||||
c.Assert(err, IsNil)
|
||||
|
|
|
@ -87,11 +87,11 @@ static int yycolumn = 1;
|
|||
"<=" { yylval->string = strdup(yytext); return OPERATION_LE; }
|
||||
">=" { yylval->string = strdup(yytext); return OPERATION_GE; }
|
||||
|
||||
[0-9]+ { yylval->string = strdup(yytext); return INT_VALUE; }
|
||||
-?[0-9]+ { yylval->string = strdup(yytext); return INT_VALUE; }
|
||||
|
||||
([0-9]+|[0-9]*\.[0-9]+|[0-9]+\.[0-9]*)[usmhdw] { yylval->string = strdup(yytext); return DURATION; }
|
||||
|
||||
[0-9]*\.[0-9]+|[0-9]+\.[0-9]* { yylval->string = strdup(yytext); return FLOAT_VALUE; }
|
||||
-?[0-9]*\.[0-9]+|[0-9]+\.[0-9]* { yylval->string = strdup(yytext); return FLOAT_VALUE; }
|
||||
|
||||
true|false { yylval->string = strdup(yytext); return BOOLEAN_VALUE; }
|
||||
|
||||
|
|
Loading…
Reference in New Issue