Skip to content

Commit

Permalink
fix: [2.5] expression with capital AND and OR are not recognized (#38928
Browse files Browse the repository at this point in the history
)

fix #38864
AND, OR and NOT is not recognized in milvus parser

master pr: #38927

Signed-off-by: Cai Zhang <[email protected]>
  • Loading branch information
xiaocai2333 authored Jan 2, 2025
1 parent 5fb8313 commit 4533fc8
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 302 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -554,3 +554,7 @@ mmap-migration:
mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && \
GO111MODULE=on $(GO) build -pgo=$(PGO_PATH)/default.pgo -ldflags="-r $${RPATH} -X '$(OBJPREFIX).BuildTags=$(BUILD_TAGS)' -X '$(OBJPREFIX).BuildTime=$(BUILD_TIME)' -X '$(OBJPREFIX).GitCommit=$(GIT_COMMIT)' -X '$(OBJPREFIX).GoVersion=$(GO_VERSION)'" \
-tags dynamic -o $(INSTALL_PATH)/mmap-migration $(MMAP_MIGRATION_PATH)/main.go 1>/dev/null

generate-parser:
@echo "Updating milvus expression parser"
@(cd $(PWD)/internal/parser/planparserv2 && env bash generate.sh)
6 changes: 3 additions & 3 deletions internal/parser/planparserv2/Plan.g4
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ BAND: '&';
BOR: '|';
BXOR: '^';

AND: '&&' | 'and';
OR: '||' | 'or';
AND: '&&' | 'and' | 'AND';
OR: '||' | 'or' | 'OR';

BNOT: '~';
NOT: '!' | 'not';
NOT: '!' | 'not' | 'NOT';

IN: 'in' | 'IN';
EmptyArray: '[' (Whitespace | Newline)* ']';
Expand Down
4 changes: 3 additions & 1 deletion internal/parser/planparserv2/generate.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env sh

alias antlr4='java -Xmx500M -cp "../../../scripts/antlr-4.13.2-complete.jar:$CLASSPATH" org.antlr.v4.Tool'
antlr4() {
java -Xmx500M -cp "../../../scripts/antlr-4.13.2-complete.jar:$CLASSPATH" org.antlr.v4.Tool "$@"
}
rm -fr generated
antlr4 -Dlanguage=Go -package planparserv2 -o generated -no-listener -visitor Plan.g4
2 changes: 1 addition & 1 deletion internal/parser/planparserv2/generated/PlanLexer.interp

Large diffs are not rendered by default.

Loading

0 comments on commit 4533fc8

Please sign in to comment.