-
Notifications
You must be signed in to change notification settings - Fork 3.6k
HHH-19297 Register SingleStore json functions to community SingleStoreDialect #9927
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
base: main
Are you sure you want to change the base?
HHH-19297 Register SingleStore json functions to community SingleStoreDialect #9927
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using ANY
for JSON arguments, please use FunctionParameterType.IMPLICIT_JSON
.
Also, instead of adding the dialect specific functions, it would probably be nicer if you could try to implement the "standardized" functions as described here for this dialect when possible/reasonable: https://docs.jboss.org/hibernate/orm/7.0/userguide/html_single/Hibernate_User_Guide.html#hql-functions-json
9c7c200
to
34fc204
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good already, but the current implementation doesn't seem to support all types of data in JSON yet. Also, checking just for instanceof UnparsedNumericLiteral<?>
isn't really checking if an expression is a numeric. An expression obviously can also be arithmetic or come from a column etc.. I proposed a different solution to this typing issue.
I can also merge the PR as it is, though it's incomplete AFAICT. Let me know what you want.
...n/java/org/hibernate/community/dialect/function/json/SingleStoreJsonArrayAppendFunction.java
Outdated
Show resolved
Hide resolved
...n/java/org/hibernate/community/dialect/function/json/SingleStoreJsonArrayInsertFunction.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/hibernate/community/dialect/function/json/SingleStoreJsonSetFunction.java
Outdated
Show resolved
Hide resolved
@beikov Thank you for your review. I'll try to make improvements based on your suggestions and will let you know. |
@beikov take a look please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thanks for putting in the effort to make this compatible with our standard functions :)
One last question. Do you run the hibernate-core testsuite against a SingleStore database? If you do, it might be nice to add an entry to docker_db.sh
and local-build-plugins/src/main/groovy/local.databases.gradle
to allow other users to also do that.
I have the feeling that if you try to e.g. set a JSON object as value on a JSON object, that the current logic might fail. Consider an HQL expression like json_set('{}', '$.a', json_array())
.
AFAIU your code, it calls to_json()
on the result of json_array()
. I guess for the database, the result of json_array()
is of type json
, but in case it treats this as "string", the invocation might produce {"a":"[]"}
, whereas it should produce {"a":[]}
. This is something that could be caught by running the hibernate-core testsuite.
e9b491d
to
129c154
Compare
@beikov The latest commit was tested using: |
129c154
to
e3d3910
Compare
HHH-19297
Small improvement for community SingleStoreDialect
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-19297