Skip to content

Let each database dialect describe its own column types, fixes #7997 - #8017

Merged
hansva merged 2 commits into
apache:mainfrom
hansva:7997
Aug 20, 2026
Merged

Let each database dialect describe its own column types, fixes #7997#8017
hansva merged 2 commits into
apache:mainfrom
hansva:7997

Conversation

@hansva

@hansva hansva commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

The goal of this PR is to let database dialects map their own types.

This removes the need to use isDatabaseVariant flags inside Database and ValueMeta.
It also introduces a plugin system where developers can add extra mappings for specific database types.
For example, if there is a plugin that wants to introduce Oracle GEOMETRY mapping for their own Hop Value types, they can do so without having to change core code.

This PR also contains golden sets containing the current mapping of Hop types to database types.
It can be used to find current gaps and fix them

All existing code has remained untouched, keeping everything backwards compatible.

Size of the PR

Golden sets to identify mistakes/see conversion results

Most of the code is generated golden sets, which will tell you how each database type is now mapping hop types -> database types. This can be used to identify mistakes.

e.g., PostgreSQL turns integers without length into DOUBLE PRECISION fields:

INTEGER      len=      -1 prec=  -1 -        -> DOUBLE PRECISION
INTEGER      len=       0 prec=   0 -        -> DOUBLE PRECISION

classloader change

It also introduces classloader groups on all database types so external plugins can safely hook into the same classloaders to add rules.

new plugin type

A DatabaseTypeRulesPlugin type has been added to introduce new rules on existing database types


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Run mvn clean install apache-rat:check to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
  • If you have a group of commits related to the same change, please squash your commits into one and force push your branch using git rebase -i.
  • Mention the appropriate issue in your description (for example: addresses #123), if applicable.

To make clear that you license your contribution under the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@hansva
hansva marked this pull request as draft August 19, 2026 08:48
@mattcasters

Copy link
Copy Markdown
Contributor

Issue #7997 is interesting. Related but not the same: I do think that data engineers will want to define (override) Hop Type to Database column types themselves. This is behind work done here: https://github.com/mattcasters/hop-data-vault/tree/main/src/main/java/org/apache/hop/datavault/metadata/targettypemapping

@hansva

hansva commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

That's interesting indeed!

@hansva
hansva marked this pull request as ready for review August 19, 2026 09:38
@mattcasters

Copy link
Copy Markdown
Contributor

Mind you, it needs support tooling to use this metadata like the DDL transform, or in the case of the plugin, an action that can automatically generate the DDL/DML for data vault, business vault or dimensional model tables and indexes.

@hansva

hansva commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

I'll investigate a bit further, but I think we are both somewhat on the same path here.

There will be a registry with rules that are being applied to do bidirectional type mapping, and external plugins can add their own mappings.
The only difference I see here is that what's currently in this PR is at a global level, and the TargetTypeMappingRule in your code is at the connection level, which is a nice user-level override.

I'll make sure the code keeps playing along nicely, we should be moving forward not backwards with these types of changes

@hansva
hansva marked this pull request as draft August 19, 2026 11:40
@mattcasters

Copy link
Copy Markdown
Contributor

Both inbound and outbound data type mappings can live in user-space. They should never be conflated and be source specific, not even databsae specific. For example, Iceberge v1/2 doesn't provide lengths and precisions for data types. This means that it's something that users would want to supply themselves before the data ends up in an EDW.

All that I see as being separate to what you seem to be doing here, providing better support for, allowing rules to be defined for data typing by database plugins. I think it's a nice improvement. Don't worry about the hop-data-vault code, it's handling a separate challenge: source --> data catalog --> target

hansva and others added 2 commits August 19, 2026 16:46
The developer manual had nothing about databases, which is Hop's largest plugin
family: around fifty dialects, and forty-five pages in the user manual telling
people how to connect to them, against two passing mentions of IDatabase for
anyone wanting to add one.

Adds a database section covering what a database plugin is made of, writing a
dialect, how column types are decided and declared, when a value needs a binding
rather than a type rule, and how a plugin can add a database specific type such
as Oracle's SDO_GEOMETRY without a change to Hop or to the plugin it extends.
Also a page on testing, since the golden files only work if people know that a
changed golden is a change to the SQL a user's database receives, and one on
migrating off the deprecated isXVariant() methods.

Value types get their own page outside the database section, because adding a
Hop data type is a row concern; supporting a database specific type needs both
halves and each links to the other.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hansva
hansva marked this pull request as ready for review August 20, 2026 07:08
@hansva
hansva merged commit 3621404 into apache:main Aug 20, 2026
4 checks passed
@hansva
hansva deleted the 7997 branch August 20, 2026 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants