Let each database dialect describe its own column types, fixes #7997 - #8017
Conversation
|
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 |
|
That's interesting indeed! |
|
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. |
|
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. I'll make sure the code keeps playing along nicely, we should be moving forward not backwards with these types of changes |
|
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: |
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>
The goal of this PR is to let database dialects map their own types.
This removes the need to use
isDatabaseVariantflags 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:
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
DatabaseTypeRulesPlugintype has been added to introduce new rules on existing database typesThank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean install apache-rat:checkto make sure basic checks pass. A more thorough check will be performed on your pull request automatically.git rebase -i.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.