fix: Revert add a sign (positive or negative) to constants (#41191)

issue: #41174

Signed-off-by: Cai Zhang <cai.zhang@zilliz.com>
This commit is contained in:
cai.zhang 2025-04-10 14:54:28 +08:00 committed by GitHub
parent b593bfd9a5
commit 6f4dc8dda2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 268 additions and 329 deletions

View File

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

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

View File

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