fix: [2.5] Revert add a sign (positive or negative) to constants (#41192)

issue: #41174
master pr: #41191

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
pull/41221/head
cai.zhang 2025-04-09 20:06:27 +08:00 committed by GitHub
parent 7001474914
commit 23c86af730
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 205 additions and 266 deletions

View File

@ -1,8 +1,8 @@
grammar Plan;
expr:
(ADD | SUB)? IntegerConstant # Integer
| (ADD | SUB)? FloatingConstant # Floating
IntegerConstant # Integer
| FloatingConstant # Floating
| BooleanConstant # Boolean
| StringLiteral # String
| (Identifier|Meta) # Identifier

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -93,7 +93,7 @@ func (v *ParserVisitor) VisitBoolean(ctx *parser.BooleanContext) interface{} {
// VisitInteger translates expr to GenericValue.
func (v *ParserVisitor) VisitInteger(ctx *parser.IntegerContext) interface{} {
literal := ctx.GetText()
literal := ctx.IntegerConstant().GetText()
i, err := strconv.ParseInt(literal, 0, 64)
if err != nil {
return err
@ -113,7 +113,7 @@ func (v *ParserVisitor) VisitInteger(ctx *parser.IntegerContext) interface{} {
// VisitFloating translates expr to GenericValue.
func (v *ParserVisitor) VisitFloating(ctx *parser.FloatingContext) interface{} {
literal := ctx.GetText()
literal := ctx.FloatingConstant().GetText()
f, err := strconv.ParseFloat(literal, 64)
if err != nil {
return err

View File

@ -182,7 +182,6 @@ func TestExpr_UnaryRange(t *testing.T) {
`VarCharField <= "str7"`,
`JSONField["A"] > 10`,
`$meta["A"] > 10`,
`A == -9223372036854775808`,
}
for _, exprStr := range exprStrs {
assertValidExpr(t, helper, exprStr)
@ -638,6 +637,7 @@ func TestExpr_Invalid(t *testing.T) {
`"str" != false`,
`VarCharField != FloatField`,
`FloatField == VarCharField`,
`A == -9223372036854775808`,
// ---------------------- relational --------------------
//`not_in_schema < 1`, // maybe in json
//`1 <= not_in_schema`, // maybe in json