Mihir-Rabari opened a new pull request, #3370:
URL: https://github.com/apache/hugegraph/pull/3370
The Cypher endpoint rejects the standard `date()` constructor with
`Unknown function 'date'` because the cypher-for-gremlin translator ships a
fixed function list that contains no temporal functions. That list lives
inside the translator dependency, so there is no way to register new
functions from HugeGraph; instead I fold the temporal constructors on the
HugeGraph side. Right before translation, `date()`, `datetime()` and
`localdatetime()` calls with a foldable argument (no argument, a string
literal, or a parameter bound to a string) are rewritten into a synthetic
bound parameter carrying a `java.util.Date`, the value HugeGraph already
uses for DATE properties.
Calls that cannot be folded (`date(n.x)`, `date('tomorrow')`, map-argument
forms) and the remaining temporal functions (`time()`, `localtime()`,
`duration()`) are left untouched and keep failing with the translator's
original error, so behavior only changes for queries that used to be
rejected outright.
Notes on the implementation:
- The rewrite runs on a copy of the parsed statement and the copy is swapped
in only when the whole fold succeeds, so a fold failure degrades to
today's error instead of a half-rewritten query.
- The synthetic parameter names are prefixed with two spaces, the same
reserved-name trick the translator uses for its generated bindings, so
they cannot collide with names a query can express.
- The bare `RETURN date()` fixture in CypherErrorTest now translates (it
folds to the current date), so I replaced it with `RETURN duration('P1Y')`
to keep the unknown-function error path covered.
- Unit tests cover literal, parameter, bare, nested and CREATE-side folds
plus the non-foldable fallbacks; CypherApiTest gains end-to-end cases for
matching a DATE property and for a date value meeting a TEXT property.
Fixes #3318
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]