hibernate-orm icon indicating copy to clipboard operation
hibernate-orm copied to clipboard

HHH-19297 Register SingleStore json functions to community SingleStoreDialect

Open oyeliseiev-ua opened this issue 9 months ago • 5 comments

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

oyeliseiev-ua avatar Mar 28 '25 11:03 oyeliseiev-ua

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.

@beikov Thank you for your review. I'll try to make improvements based on your suggestions and will let you know.

oyeliseiev-ua avatar Apr 16 '25 10:04 oyeliseiev-ua

@beikov take a look please

oyeliseiev-ua avatar Apr 16 '25 16:04 oyeliseiev-ua

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.

@beikov I have the test suite configuration on a separate branch, intended for local execution only. I'm concerned about maintainability due to specific SingleStore limitations—many tests need to be marked as skipped or have their logic adjusted. If that's acceptable, I'd like to create a separate PR for this.

The latest commit was tested using: org.hibernate.orm.test.function.json.* and org.hibernate.orm.test.query.hql.JsonFunctionTests.java

oyeliseiev-ua avatar Apr 17 '25 18:04 oyeliseiev-ua

Hi @beikov . Is it okay to proceed with merging this PR?

oyeliseiev-ua avatar May 09 '25 10:05 oyeliseiev-ua

The changes look good to me, but we're in the process of doing the final ORM 7.0 release, so we won't merge any new features at this point. I'll get back to this once we branch off for ORM 7.0 and main becomes ORM 7.1-SNAPSHOT.

beikov avatar May 15 '25 16:05 beikov

Please rebase your PR @oyeliseiev-ua

beikov avatar Jun 18 '25 14:06 beikov