Skip to content

Conversation

@sakthivelmanii
Copy link
Contributor

@sakthivelmanii sakthivelmanii commented Jan 8, 2026

[Please describe here what your change is about]

Created a basic version of Spanner version of Dialect

  1. Fixed all the features that needs to be enabled / disbled
  2. Added support for table creation without primary key
  3. Added support for dropping indexes before dropping the table
  4. Added support for sequences
  5. Added support for creating unique index

Upcoming:

  1. Add support for types
  2. Add support for temporary tables
  3. Add support for locking ..etc

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-20050

@sakthivelmanii sakthivelmanii force-pushed the create_spanner_postgresql_dialect branch from f653970 to 1d7bdc0 Compare January 8, 2026 20:52
import org.hibernate.procedure.spi.CallableStatementSupport;
import org.hibernate.tool.schema.internal.StandardTableExporter;

public class SpannerPostgreSQLDialect extends PostgreSQLDialect {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With all the overrides here and potentially missed cases in the SqlAstTranslator I'm kind of starting to think that extending the PostgreSQLDialect is not a good idea.
The use of the Spanner JDBC driver in Database#SPANNER_PG also makes me think that it might be better to extend the SpannerDialect here and override the functions and DDL types or whatever is different from standard Spanner.
Finally, I would prefer to move this dialect to the hibernate-community-dialects project until we can figure out a way to regularly test it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beikov Spanner PG is more aligned(more closer) with PostgreSQL compared to Spanner dialect. I agree that we override lot of methods. We have plans on providing support for them so that we can get rid of these overriden methods. The current dialect shows the gist of what's different compared to OSS PG.

I am trying to onboard the dialect in phases so that it will be easy for review(though I have fixed all the tests in my local). I am planning to onboard testing in CI as soon as I make all changes related to the Dialect. Do you suggest we should move to community dialect first and later bring it to core once we configure the testing pipeline?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to onboard the dialect in phases so that it will be easy for review(though I have fixed all the tests in my local).

What do you mean by "fixed all the tests"? I would hope that we don't require many @SkipDialect uses.

I am planning to onboard testing in CI as soon as I make all changes related to the Dialect. Do you suggest we should move to community dialect first and later bring it to core once we configure the testing pipeline?

Yes please. Until we can properly and regularly test this new dialect, I would prefer to have it in the community dialects module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beikov

What do you mean by "fixed all the tests"? I would hope that we don't require many @SkipDialect uses.

Spanner doesn't support integer sequences due to it's nature as a distributed databases(to avoid hotspots). We might have to disable some tests which uses integer identity column(@id with Integer).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beikov Thanks for the suggestions. I have moved the dialect to inside community dialect.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spanner doesn't support integer sequences due to it's nature as a distributed databases(to avoid hotspots). We might have to disable some tests which uses integer identity column(@id with Integer).

Cockroach has a similar problem and solved it in the past by always emitting serial8 or int8 as column type. See CockroachDBIdentityColumnSupport

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beikov I think cockroach serial type has a capability to produce auto-incrementing sequences of int type(to avoid hotspots). In Spanner, serial type also produces Long values which can't fit into Integer type.

Copy link
Member

@mbellade mbellade Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sakthivelmanii this is fine for now, though it'll need to be addressed once we aim to set-up testing and move this into core.

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Jan 9, 2026

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@sakthivelmanii sakthivelmanii force-pushed the create_spanner_postgresql_dialect branch 2 times, most recently from 61c16a4 to c443500 Compare January 9, 2026 14:32
@sakthivelmanii sakthivelmanii force-pushed the create_spanner_postgresql_dialect branch from fab4e1e to d5c82a1 Compare January 10, 2026 07:08
@sakthivelmanii
Copy link
Contributor Author

@beikov Can we merge this?

@sakthivelmanii sakthivelmanii force-pushed the create_spanner_postgresql_dialect branch from d5c82a1 to 823386d Compare January 12, 2026 12:46
@sakthivelmanii sakthivelmanii force-pushed the create_spanner_postgresql_dialect branch 5 times, most recently from a508bb5 to d8ce825 Compare January 13, 2026 09:30
@sakthivelmanii
Copy link
Contributor Author

@beikov @gavinking can we please merge this if everything is okay?

Copy link
Member

@gavinking gavinking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One very minor thing, but apart from that I have no further objection.

@sakthivelmanii sakthivelmanii force-pushed the create_spanner_postgresql_dialect branch 2 times, most recently from da81691 to bfc8759 Compare January 13, 2026 09:47
@sakthivelmanii
Copy link
Contributor Author

One very minor thing, but apart from that I have no further objection.

All the issues are fixed from my side. there was a bug when I moved dialect from core to community.

@sakthivelmanii
Copy link
Contributor Author

@gavinking Can we merge this?

@gavinking
Copy link
Member

Don't look at me, not my area.

@sakthivelmanii
Copy link
Contributor Author

@beikov @mbellade Can you please help merging this PR?

@mbellade
Copy link
Member

@sakthivelmanii static code analysis is failing, please run ./gradlew spotlessApply to fix it

@sakthivelmanii sakthivelmanii force-pushed the create_spanner_postgresql_dialect branch from bfc8759 to 8e44b30 Compare January 14, 2026 13:43
@sakthivelmanii
Copy link
Contributor Author

@mbellade Thanks. I have pushed the code again.

@mbellade
Copy link
Member

Great, please squash everything to a single commit and we're good to go

@sakthivelmanii sakthivelmanii force-pushed the create_spanner_postgresql_dialect branch from 8e44b30 to 1e39292 Compare January 14, 2026 13:46
@sakthivelmanii
Copy link
Contributor Author

@mbellade Thanks. I have squashed into one commit.

@sakthivelmanii sakthivelmanii force-pushed the create_spanner_postgresql_dialect branch from 1e39292 to 73598b6 Compare January 14, 2026 14:00
@sakthivelmanii
Copy link
Contributor Author

@mbellade It was failing with this error #11585. I rebased with the latest main branch

@sakthivelmanii
Copy link
Contributor Author

@mbellade build is green. Jenkins CI (hibernate-orm-pipeline) is not approved.

@mbellade mbellade merged commit 4d75c7a into hibernate:main Jan 14, 2026
22 of 24 checks passed
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.

4 participants