You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the second case (-9223372036854775808) triggers an out-of-range error:
Error: Received unexpected error:
parse error at line 1, col 4: strconv.Atoi: parsing "9223372036854775808": value out of range
Test: TestSpansetFilterStatics/{_-9223372036854775808_}
It appears the parser handles the numeric part (9223372036854775808) as a positive integer before applying the minus sign, causing the overflow.
A possible approach is to handle negative bounds explicitly, similar to how TiDB deals with it. They parse the numeric literal without the sign, then apply a range check for [-9223372036854775808, 9223372036854775807]. Here’s a snippet illustrating that approach:
SignedNum:
Int64Num
| '+' Int64Num
{
$$ = $2
}
| '-' NUM
{
unsigned_num := getUint64FromNUM($2)
if unsigned_num > 9223372036854775808 {
yylex.AppendError(yylex.Errorf("the Signed Value should be at the range of [-9223372036854775808, 9223372036854775807]."))
return1
} elseif unsigned_num == 9223372036854775808 {
signed_one := int64(1)
$$ = signed_one << 63
} else {
$$ = -int64(unsigned_num)
}
}
By incorporating a similar boundary check into TraceQL’s parser, -9223372036854775808 will no longer fail with an out-of-range error.
The text was updated successfully, but these errors were encountered:
Thanks for the issue! I would be glad to accept a PR to fix, but given how minor this issue is, the PR would need to add very little complexity to Tempo.
BTW, if you choose to solve the issue by modifying expr.y, I would suggest asking the Grafana team which version of goyacc they are using. I found that it's definitely not the latest one, because the code I generated differed too much from the original. The version that produced the closest match to the original code was v0.1.0
Describe the bug
When adding test cases to
TestSpansetFilterStatics
:the second case (
-9223372036854775808
) triggers an out-of-range error:It appears the parser handles the numeric part (
9223372036854775808
) as a positive integer before applying the minus sign, causing the overflow.The relevant parsing rule is in expr.y:
A possible approach is to handle negative bounds explicitly, similar to how TiDB deals with it. They parse the numeric literal without the sign, then apply a range check for [
-9223372036854775808
,9223372036854775807
]. Here’s a snippet illustrating that approach:By incorporating a similar boundary check into TraceQL’s parser,
-9223372036854775808
will no longer fail with an out-of-range error.The text was updated successfully, but these errors were encountered: