Skip to content

feat: add function expression support to JDQL grammar and parser#714

Merged
otaviojava merged 5 commits into
eclipse-jnosql:mainfrom
omatheusmesmo:feat/643-jdql-function-support
Apr 19, 2026
Merged

feat: add function expression support to JDQL grammar and parser#714
otaviojava merged 5 commits into
eclipse-jnosql:mainfrom
omatheusmesmo:feat/643-jdql-function-support

Conversation

@omatheusmesmo
Copy link
Copy Markdown

@omatheusmesmo omatheusmesmo commented Apr 6, 2026

Description

Adds grammar and parser support for scalar function expressions (ABS, LENGTH, LOWER, UPPER, LEFT, RIGHT) in JDQL queries. After this, queries like SELECT e FROM Entity e WHERE ABS(e.salary) > 1000 just work.

Step 2 of 3 from the PR #704 split.

Related Issue: Related to #643

Type of Contribution

  • Bug fix
  • Feature request
  • New database support
  • Use case implementation
  • Documentation update
  • Other:

Architectural and Design Decisions

  • All new types (DefaultFunction, FunctionQueryValue, FunctionType) are package-private inside the data subpackage.
  • FunctionType is an enum that replaces the if-else chain in PrimaryFunction.
  • The grammar adds an identifier rule that includes function tokens (ABS, LENGTH, etc.) to keep backward compatibility — without it, fields named length, left, etc. would stop parsing as valid field names.
  • AbstractWhere drops the exitFunction_expression override that threw UnsupportedOperationException — the grammar and PrimaryFunction handle everything now.

Contribution Checklist

  • ECA: I have signed the Eclipse Contributor Agreement.
  • DCO: All my commits are signed with Signed-off-by (git commit -s).
  • Conventional Commits: I followed the Conventional Commits pattern.
  • Tests: I have added/updated unit and integration tests.
  • Documentation: I have updated the relevant .adoc files.
  • Verification: I have run mvn clean verify and it passed successfully.

Validation Results

mvn -B clean install
BUILD SUCCESS (JDK 21 and JDK 25)

Matheus Oliveira added 5 commits April 4, 2026 09:23
Introduces DefaultFunction and FunctionQueryValue to represent
scalar function calls within JDQL query values. Both types are
package-private, keeping implementation details out of the public API.
Also updates the changelog.

Issue eclipse-jnosql#643

Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Updates the ANTLR4 grammar to support ABS, LENGTH, LOWER, UPPER,
LEFT, and RIGHT functions. Ensures function keywords can still be
used as field identifiers to maintain backward compatibility.

Issue eclipse-jnosql#643

Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Enhances PrimaryFunction to process function expression nodes from
the AST, converting them into FunctionQueryValue objects. Introduces
FunctionType enum to normalize function names and enforce arity
validation per the Jakarta Data specification. Enables recursive
parsing of nested function arguments. Arithmetic expressions within
function arguments are explicitly rejected as unsupported.

Issue eclipse-jnosql#643

Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Updates AbstractWhere to support function expressions within query
conditions, allowing them to be processed by the JDQL provider.

Issue eclipse-jnosql#643

Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
Covers single-parameter functions (UPPER, LOWER, LENGTH, ABS),
multi-parameter functions (LEFT, RIGHT), nested function calls,
named parameters, field name collision with function keywords,
wrong arity rejection, and arithmetic expression rejection.

Issue eclipse-jnosql#643

Signed-off-by: Matheus Oliveira <hi@omatheusmesmo.dev>
@otaviojava otaviojava merged commit 7099953 into eclipse-jnosql:main Apr 19, 2026
3 checks passed
@otaviojava
Copy link
Copy Markdown
Contributor

sorry for take longer @omatheusmesmo , meged it.

Thank you

@omatheusmesmo
Copy link
Copy Markdown
Author

sorry for take longer @omatheusmesmo , meged it.

Thank you

No problems, thank you too.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants