Skip to content

The FilterExpressionTextParser cannot parse Long type values #3509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mucheng2035 opened this issue Jun 11, 2025 · 2 comments · May be fixed by #3516
Closed

The FilterExpressionTextParser cannot parse Long type values #3509

mucheng2035 opened this issue Jun 11, 2025 · 2 comments · May be fixed by #3516

Comments

@mucheng2035
Copy link

Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description

Environment
Spring-ai 1.0.0

Steps to reproduce
@test
public void testEQ() {
// country == "BG"
Expression exp2 = this.parser.parse("biz_id == 3L");
assertThat(exp2).isEqualTo(new Expression(EQ, new Key("biz_id"), new Value(3L)));

}

Expected behavior
Support long type parsing

Minimal Complete Reproducible example
@test
public void testEQ() {
// country == "BG"

	Expression exp2 = this.parser.parse("biz_id == 3L");
	assertThat(exp2).isEqualTo(new Expression(EQ, new Key("biz_id"), new Value(3L)));

}

Temporary solution
I am not familiar with antlr4, and the temporary solution is as follows:

org.springframework.ai.vectorstore.filter.FilterExpressionTextParser.FilterExpressionVisitor#visitIntegerConstant
	public Filter.Operand visitIntegerConstant(FiltersParser.IntegerConstantContext ctx) {
			long value = Long.parseLong(ctx.getText());
			if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE) {
				return new Filter.Value(value);
			}
			return new Filter.Value((int)value);
		}
sunyuhan1998 added a commit to sunyuhan1998/spring-ai that referenced this issue Jun 12, 2025
…ionTextParser failed to parse Long type values.

Signed-off-by: Sun Yuhan <[email protected]>
@sunyuhan1998
Copy link
Contributor

Hi @mucheng2035 thanks for the report, it's true that it doesn't have specific support for the Long type right now, I've submitted a PR to support it: #3516

@mucheng2035
Copy link
Author

@sunyuhan1998 thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants