{s:`SELECT count(value) FROM foo where time > now() and time < now() group by time(1s, b)`,err:`time dimension offset must be duration or now()`},
{s:`SELECT count(value) FROM foo where time > now() and time < now() group by time(1s, '5s')`,err:`time dimension offset must be duration or now()`},
{s:`SELECT distinct(field1), sum(field1) FROM myseries`,err:`aggregate function distinct() cannot be combined with other functions or fields`},
{s:`SELECT distinct(field1), field2 FROM myseries`,err:`aggregate function distinct() cannot be combined with other functions or fields`},
{s:`SELECT distinct(field1, field2) FROM myseries`,err:`distinct function can only have one argument`},
{s:`SELECT distinct() FROM myseries`,err:`distinct function requires at least one argument`},
{s:`SELECT distinct field1, field2 FROM myseries`,err:`aggregate function distinct() cannot be combined with other functions or fields`},
{s:`SELECT count(distinct field1, field2) FROM myseries`,err:`invalid number of arguments for count, expected 1, got 2`},
{s:`select count(distinct(too, many, arguments)) from myseries`,err:`distinct function can only have one argument`},
{s:`select count() from myseries`,err:`invalid number of arguments for count, expected 1, got 0`},
{s:`SELECT derivative(field1), field1 FROM myseries`,err:`mixing aggregate and non-aggregate queries is not supported`},
{s:`select derivative() from myseries`,err:`invalid number of arguments for derivative, expected at least 1 but no more than 2, got 0`},
{s:`select derivative(mean(value), 1h, 3) from myseries`,err:`invalid number of arguments for derivative, expected at least 1 but no more than 2, got 3`},
{s:`SELECT derivative(value) FROM myseries group by time(1h)`,err:`aggregate function required inside the call to derivative`},
{s:`SELECT derivative(top(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for top, expected at least 2, got 1`},
{s:`SELECT derivative(bottom(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for bottom, expected at least 2, got 1`},
{s:`SELECT derivative(max()) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for max, expected 1, got 0`},
{s:`SELECT derivative(percentile(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for percentile, expected 2, got 1`},
{s:`SELECT derivative(mean(value), 1h) FROM myseries where time < now() and time > now() - 1d`,err:`derivative aggregate requires a GROUP BY interval`},
{s:`SELECT derivative(value, -2h) FROM myseries`,err:`duration argument must be positive, got -2h`},
{s:`SELECT derivative(value, 10) FROM myseries`,err:`second argument to derivative must be a duration, got *influxql.IntegerLiteral`},
{s:`SELECT derivative(f, true) FROM myseries`,err:`second argument to derivative must be a duration, got *influxql.BooleanLiteral`},
{s:`SELECT non_negative_derivative(field1), field1 FROM myseries`,err:`mixing aggregate and non-aggregate queries is not supported`},
{s:`select non_negative_derivative() from myseries`,err:`invalid number of arguments for non_negative_derivative, expected at least 1 but no more than 2, got 0`},
{s:`select non_negative_derivative(mean(value), 1h, 3) from myseries`,err:`invalid number of arguments for non_negative_derivative, expected at least 1 but no more than 2, got 3`},
{s:`SELECT non_negative_derivative(value) FROM myseries group by time(1h)`,err:`aggregate function required inside the call to non_negative_derivative`},
{s:`SELECT non_negative_derivative(top(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for top, expected at least 2, got 1`},
{s:`SELECT non_negative_derivative(bottom(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for bottom, expected at least 2, got 1`},
{s:`SELECT non_negative_derivative(max()) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for max, expected 1, got 0`},
{s:`SELECT non_negative_derivative(mean(value), 1h) FROM myseries where time < now() and time > now() - 1d`,err:`non_negative_derivative aggregate requires a GROUP BY interval`},
{s:`SELECT non_negative_derivative(percentile(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for percentile, expected 2, got 1`},
{s:`SELECT non_negative_derivative(value, -2h) FROM myseries`,err:`duration argument must be positive, got -2h`},
{s:`SELECT non_negative_derivative(value, 10) FROM myseries`,err:`second argument to non_negative_derivative must be a duration, got *influxql.IntegerLiteral`},
{s:`SELECT difference(field1), field1 FROM myseries`,err:`mixing aggregate and non-aggregate queries is not supported`},
{s:`SELECT difference() from myseries`,err:`invalid number of arguments for difference, expected 1, got 0`},
{s:`SELECT difference(value) FROM myseries group by time(1h)`,err:`aggregate function required inside the call to difference`},
{s:`SELECT difference(top(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for top, expected at least 2, got 1`},
{s:`SELECT difference(bottom(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for bottom, expected at least 2, got 1`},
{s:`SELECT difference(max()) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for max, expected 1, got 0`},
{s:`SELECT difference(percentile(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for percentile, expected 2, got 1`},
{s:`SELECT difference(mean(value)) FROM myseries where time < now() and time > now() - 1d`,err:`difference aggregate requires a GROUP BY interval`},
{s:`SELECT non_negative_difference(field1), field1 FROM myseries`,err:`mixing aggregate and non-aggregate queries is not supported`},
{s:`SELECT non_negative_difference() from myseries`,err:`invalid number of arguments for non_negative_difference, expected 1, got 0`},
{s:`SELECT non_negative_difference(value) FROM myseries group by time(1h)`,err:`aggregate function required inside the call to non_negative_difference`},
{s:`SELECT non_negative_difference(top(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for top, expected at least 2, got 1`},
{s:`SELECT non_negative_difference(bottom(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for bottom, expected at least 2, got 1`},
{s:`SELECT non_negative_difference(max()) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for max, expected 1, got 0`},
{s:`SELECT non_negative_difference(percentile(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for percentile, expected 2, got 1`},
{s:`SELECT non_negative_difference(mean(value)) FROM myseries where time < now() and time > now() - 1d`,err:`non_negative_difference aggregate requires a GROUP BY interval`},
{s:`SELECT elapsed() FROM myseries`,err:`invalid number of arguments for elapsed, expected at least 1 but no more than 2, got 0`},
{s:`SELECT elapsed(value) FROM myseries group by time(1h)`,err:`aggregate function required inside the call to elapsed`},
{s:`SELECT elapsed(value, 1s, host) FROM myseries`,err:`invalid number of arguments for elapsed, expected at least 1 but no more than 2, got 3`},
{s:`SELECT elapsed(value, 0s) FROM myseries`,err:`duration argument must be positive, got 0s`},
{s:`SELECT elapsed(value, -10s) FROM myseries`,err:`duration argument must be positive, got -10s`},
{s:`SELECT elapsed(value, 10) FROM myseries`,err:`second argument to elapsed must be a duration, got *influxql.IntegerLiteral`},
{s:`SELECT elapsed(top(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for top, expected at least 2, got 1`},
{s:`SELECT elapsed(bottom(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for bottom, expected at least 2, got 1`},
{s:`SELECT elapsed(max()) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for max, expected 1, got 0`},
{s:`SELECT elapsed(percentile(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for percentile, expected 2, got 1`},
{s:`SELECT elapsed(mean(value)) FROM myseries where time < now() and time > now() - 1d`,err:`elapsed aggregate requires a GROUP BY interval`},
{s:`SELECT moving_average(field1, 2), field1 FROM myseries`,err:`mixing aggregate and non-aggregate queries is not supported`},
{s:`SELECT moving_average(field1, 1), field1 FROM myseries`,err:`moving_average window must be greater than 1, got 1`},
{s:`SELECT moving_average(field1, 0), field1 FROM myseries`,err:`moving_average window must be greater than 1, got 0`},
{s:`SELECT moving_average(field1, -1), field1 FROM myseries`,err:`moving_average window must be greater than 1, got -1`},
{s:`SELECT moving_average(field1, 2.0), field1 FROM myseries`,err:`second argument for moving_average must be an integer, got *influxql.NumberLiteral`},
{s:`SELECT moving_average() from myseries`,err:`invalid number of arguments for moving_average, expected 2, got 0`},
{s:`SELECT moving_average(value) FROM myseries`,err:`invalid number of arguments for moving_average, expected 2, got 1`},
{s:`SELECT moving_average(value, 2) FROM myseries group by time(1h)`,err:`aggregate function required inside the call to moving_average`},
{s:`SELECT moving_average(top(value), 2) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for top, expected at least 2, got 1`},
{s:`SELECT moving_average(bottom(value), 2) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for bottom, expected at least 2, got 1`},
{s:`SELECT moving_average(max(), 2) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for max, expected 1, got 0`},
{s:`SELECT moving_average(percentile(value), 2) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for percentile, expected 2, got 1`},
{s:`SELECT moving_average(mean(value), 2) FROM myseries where time < now() and time > now() - 1d`,err:`moving_average aggregate requires a GROUP BY interval`},
{s:`SELECT cumulative_sum(field1), field1 FROM myseries`,err:`mixing aggregate and non-aggregate queries is not supported`},
{s:`SELECT cumulative_sum() from myseries`,err:`invalid number of arguments for cumulative_sum, expected 1, got 0`},
{s:`SELECT cumulative_sum(value) FROM myseries group by time(1h)`,err:`aggregate function required inside the call to cumulative_sum`},
{s:`SELECT cumulative_sum(top(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for top, expected at least 2, got 1`},
{s:`SELECT cumulative_sum(bottom(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for bottom, expected at least 2, got 1`},
{s:`SELECT cumulative_sum(max()) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for max, expected 1, got 0`},
{s:`SELECT cumulative_sum(percentile(value)) FROM myseries where time < now() and time > now() - 1d group by time(1h)`,err:`invalid number of arguments for percentile, expected 2, got 1`},
{s:`SELECT cumulative_sum(mean(value)) FROM myseries where time < now() and time > now() - 1d`,err:`cumulative_sum aggregate requires a GROUP BY interval`},
{s:`SELECT integral() FROM myseries`,err:`invalid number of arguments for integral, expected at least 1 but no more than 2, got 0`},
{s:`SELECT integral(value, 10s, host) FROM myseries`,err:`invalid number of arguments for integral, expected at least 1 but no more than 2, got 3`},
{s:`SELECT integral(value, -10s) FROM myseries`,err:`duration argument must be positive, got -10s`},
{s:`SELECT integral(value, 10) FROM myseries`,err:`second argument must be a duration`},
{s:`SELECT holt_winters(value) FROM myseries where time < now() and time > now() - 1d`,err:`invalid number of arguments for holt_winters, expected 3, got 1`},
{s:`SELECT holt_winters(value, 10, 2) FROM myseries where time < now() and time > now() - 1d`,err:`must use aggregate function with holt_winters`},
{s:`SELECT holt_winters(min(value), 10, 2) FROM myseries where time < now() and time > now() - 1d`,err:`holt_winters aggregate requires a GROUP BY interval`},
{s:`SELECT holt_winters(min(value), 0, 2) FROM myseries where time < now() and time > now() - 1d GROUP BY time(1d)`,err:`second arg to holt_winters must be greater than 0, got 0`},
{s:`SELECT holt_winters(min(value), false, 2) FROM myseries where time < now() and time > now() - 1d GROUP BY time(1d)`,err:`expected integer argument as second arg in holt_winters`},
{s:`SELECT holt_winters(min(value), 10, 'string') FROM myseries where time < now() and time > now() - 1d GROUP BY time(1d)`,err:`expected integer argument as third arg in holt_winters`},
{s:`SELECT holt_winters(min(value), 10, -1) FROM myseries where time < now() and time > now() - 1d GROUP BY time(1d)`,err:`third arg to holt_winters cannot be negative, got -1`},
{s:`SELECT holt_winters_with_fit(value) FROM myseries where time < now() and time > now() - 1d`,err:`invalid number of arguments for holt_winters_with_fit, expected 3, got 1`},
{s:`SELECT holt_winters_with_fit(value, 10, 2) FROM myseries where time < now() and time > now() - 1d`,err:`must use aggregate function with holt_winters_with_fit`},
{s:`SELECT holt_winters_with_fit(min(value), 10, 2) FROM myseries where time < now() and time > now() - 1d`,err:`holt_winters_with_fit aggregate requires a GROUP BY interval`},
{s:`SELECT holt_winters_with_fit(min(value), 0, 2) FROM myseries where time < now() and time > now() - 1d GROUP BY time(1d)`,err:`second arg to holt_winters_with_fit must be greater than 0, got 0`},
{s:`SELECT holt_winters_with_fit(min(value), false, 2) FROM myseries where time < now() and time > now() - 1d GROUP BY time(1d)`,err:`expected integer argument as second arg in holt_winters_with_fit`},
{s:`SELECT holt_winters_with_fit(min(value), 10, 'string') FROM myseries where time < now() and time > now() - 1d GROUP BY time(1d)`,err:`expected integer argument as third arg in holt_winters_with_fit`},
{s:`SELECT holt_winters_with_fit(min(value), 10, -1) FROM myseries where time < now() and time > now() - 1d GROUP BY time(1d)`,err:`third arg to holt_winters_with_fit cannot be negative, got -1`},
{s:`SELECT mean(value) + value FROM cpu WHERE time < now() and time > now() - 1h GROUP BY time(10m)`,err:`mixing aggregate and non-aggregate queries is not supported`},
{s:`SELECT mean(cpu_total - cpu_idle) FROM cpu`,err:`expected field argument in mean()`},
{s:`SELECT derivative(mean(cpu_total - cpu_idle), 1s) FROM cpu WHERE time < now() AND time > now() - 1d GROUP BY time(1h)`,err:`expected field argument in mean()`},
// TODO: The error message will change when math is allowed inside an aggregate: https://github.com/influxdata/influxdb/pull/5990#issuecomment-195565870
{s:`SELECT count(foo + sum(bar)) FROM cpu`,err:`expected field argument in count()`},
{s:`SELECT (count(foo + sum(bar))) FROM cpu`,err:`expected field argument in count()`},
{s:`SELECT sum(value) + count(foo + sum(bar)) FROM cpu`,err:`expected field argument in count()`},
{s:`SELECT top(value, 2), max(value) FROM cpu`,err:`selector function top() cannot be combined with other functions`},
{s:`SELECT bottom(value, 2), max(value) FROM cpu`,err:`selector function bottom() cannot be combined with other functions`},
{s:`SELECT min(derivative) FROM (SELECT derivative(mean(value), 1h) FROM myseries) where time < now() and time > now() - 1d`,err:`derivative aggregate requires a GROUP BY interval`},
{s:`SELECT min(mean) FROM (SELECT mean(value) FROM myseries GROUP BY time)`,err:`time() is a function and expects at least one argument`},
{s:`SELECT value FROM (SELECT value FROM cpu ORDER BY time DESC) ORDER BY time ASC`,err:`subqueries must be ordered in the same direction as the query itself`},
{s:`SELECT sin(value, 3) FROM cpu`,err:`invalid number of arguments for sin, expected 1, got 2`},
{s:`SELECT cos(2.3, value, 3) FROM cpu`,err:`invalid number of arguments for cos, expected 1, got 3`},
{s:`SELECT tan(value, 3) FROM cpu`,err:`invalid number of arguments for tan, expected 1, got 2`},
{s:`SELECT asin(value, 3) FROM cpu`,err:`invalid number of arguments for asin, expected 1, got 2`},
{s:`SELECT acos(value, 3.2) FROM cpu`,err:`invalid number of arguments for acos, expected 1, got 2`},
{s:`SELECT atan() FROM cpu`,err:`invalid number of arguments for atan, expected 1, got 0`},
{s:`SELECT sqrt(42, 3, 4) FROM cpu`,err:`invalid number of arguments for sqrt, expected 1, got 3`},
{s:`SELECT abs(value, 3) FROM cpu`,err:`invalid number of arguments for abs, expected 1, got 2`},
{s:`SELECT ln(value, 3) FROM cpu`,err:`invalid number of arguments for ln, expected 1, got 2`},
{s:`SELECT log2(value, 3) FROM cpu`,err:`invalid number of arguments for log2, expected 1, got 2`},
{s:`SELECT log10(value, 3) FROM cpu`,err:`invalid number of arguments for log10, expected 1, got 2`},
{s:`SELECT pow(value, 3, 3) FROM cpu`,err:`invalid number of arguments for pow, expected 2, got 3`},
{s:`SELECT atan2(value, 3, 3) FROM cpu`,err:`invalid number of arguments for atan2, expected 2, got 3`},
{s:`SELECT sin(1.3) FROM cpu`,err:`field must contain at least one variable`},
{s:`SELECT nofunc(1.3) FROM cpu`,err:`undefined function nofunc()`},