Hi all, I'd like to kick off a design discussion around column default
values in the DDL pipeline. The issue is currently tracked in #13217 [1],
and as per the STIP guide I'll raise a [STIP-45] issue once we've got some
direction on this.

The short version is that Column.defaultValue is a bare Object and the
three stages of the pipeline have very different ideas about what it means.
The MySQL JDBC catalog will store whatever
INFORMATION_SCHEMA.COLUMNS.COLUMN_DEFAULT contains in MySQL 8 (i.e.
expression text such as CURRENT_TIMESTAMP or (uuid())), and the catalog
never reads EXTRA so an expression and a string literal look exactly the
same. The CDC sources build the column differently: Debezium parses the
DDL, keeps special expressions as raw values, and converts all others to
literals. On the target side the MysqlCreateTableSqlBuilder doesn't emit a
DEFAULT clause at all (only the DuckDB builder does, via raw toString
concat), whereas JdbcDialect.applySchemaChange only emits defaults when the
source and sink dialects match, with various per-dialect policies on top of
that.

So the same table can end up with its defaults completely lost on
auto-create, have 'now()' rendered as a string literal across dialects and
arrive at the target with different Java types depending on whether it was
read via the catalog or via CDC.

The direction I'd like to get feedback on (all the details in the STIP
draft I'll link from #13217):
* A typed DefaultValue model in seatunnel-api, sitting alongside the
existing field. Nothing reinterprets the old metadata and the 25+ existing
readers of getDefaultValue() will continue to work unchanged.
* A closed v1 vocabulary: typed literals, explicit NULL and the current
time expression family (CURRENT_TIMESTAMP/TIME/DATE with optional
precision). Everything else is positively marked as UNSUPPORTED and will
never be emitted into the target SQL via any form of guessing.
* Policy: fail the schema operation by default when a default cannot be
represented on the target, with an opt-in to drop the clause and warn. I
know that FAIL by default will change the behaviour of jobs that currently
silently auto-create tables with expression defaults (that's the main thing
I'd like to get feedback on).
* Converter vs dialect: the central converter normalises semantics, the
target dialect owns the final SQL. The same text doesn't necessarily mean
the same thing across engines (CURRENT_TIMESTAMP in MySQL vs PostgreSQL for
example have different evaluation timing), so I don't think the central
converter should be responsible for generating the final SQL.
* Scope: MySQL source, MySQL target, both auto-create and same dialect
evolution paths (with an executable test matrix). CDC schema evolution and
cross database mapping are out of v1.

The four boundaries from the maintainer feedback on the issue
(compatibility, vocabulary, unsupported policy and scope/proof) are all
explicitly addressed in the draft.Links:[1]
https://github.com/apache/seatunnel/issues/13217[2] STIP guide:
https://seatunnel.apache.org/community/contribution_guide/STIP/ Thanks,
Sainimal (Github: @sainimal1ba-hue)

Reply via email to