Explore infrastructure for Dialect-specific `Criteria`
This pull request explores the necessary infrastructure so that a Dialect-specific extension can be provided to render Database-specific operators and functions for usage in Criteria (and later on Select Items and Order By).
To verify assumptions, we've provided a Postgres-specific dialect extension with:
- Support for Array, JSON, and Vector Search functions and operators
- Expressions to reference columns (property paths)
- Initial support for Query Mapping using the R2DBC Query Mapper
Criteria Infrastructure requires details about typing and property to column (including joins) mapping to consider quotation, column names and target type conversion.
TODO:
- [ ] Discuss
QueryExpresswith its nested interfaces and methods - [ ] Decide on
PgSqlAPI style - [ ] Determine whether we really need the
BindMarkerscopy (org.springframework.data.relational.core.bindingpackage)
Syntax Variants
Functional Transformation (left-hand-side)
PgSql.where("embedding", it -> it.distanceTo(Vector.of(1, 2, 3), Distances::cosine)).lessThan("0.8")
.and("some_json", it -> it.json().field("country")).is("Some Country");
Functional Transformation (right-hand-side)
PgSql.where("tags").json(it -> it.containsAll("electronics", "gaming"))
Fluent API per Entrypoint
PgSql.where(PgSql.vectorSearch().distanceOf("embedding", Vector.of(1, 2, 3)).cosine()).lessThan(0.8);
Fluent API (right-hand-side)
PgSql.where("tags").arrays().overlaps("country");
Each style contributes some useful details and we have to discuss for the Postgres-specific part, how we want to expose the API. We want to generally avoid a style that would e.g. make use of many braces (e.g. asBoolean(field(json("some_json"), "country"))) as counting closing-braces and inner braces is detrimental to code readability.