[jOOQ/jOOQ#18707] MetaDataFieldProvider debug logs warnings about

Nullable(xyz) types not being supported for ClickHouse
This commit is contained in:
Lukas Eder 2025-07-03 09:03:46 +02:00
parent 69561c3339
commit 90eccecf56
2 changed files with 23 additions and 2 deletions

View File

@ -165,6 +165,11 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
*/
private static final Pattern P_NORMALISE = Pattern.compile("\"|\\.|\\s|\\(\\w+(\\s*,\\s*\\w+)*\\)|(NOT\\s*NULL)?");
/**
* A pattern for data type name normalisation.
*/
private static final Pattern P_NULLABLE = Pattern.compile("^Nullable\\((.*)\\)$");
/**
* A pattern to be used to replace all precision, scale, and length
* information.
@ -412,7 +417,7 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
// [#3225] Avoid normalisation if not necessary
if (!TYPES_BY_NAME[ordinal].containsKey(typeName.toUpperCase()))
TYPES_BY_NAME[ordinal].putIfAbsent(DefaultDataType.normalise(typeName), this);
TYPES_BY_NAME[ordinal].putIfAbsent(DefaultDataType.normalise(dialect, typeName), this);
TYPES_BY_TYPE[ordinal].putIfAbsent(type, this);
if (sqlDataType != null)
@ -708,7 +713,7 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
// [#3225] Normalise only if necessary
if (result == null) {
result = TYPES_BY_NAME[ordinal].get(normalised = DefaultDataType.normalise(typeName));
result = TYPES_BY_NAME[ordinal].get(normalised = DefaultDataType.normalise(dialect, typeName));
// UDT data types and built-in array data types are registered using DEFAULT
if (result == null) {
@ -1052,6 +1057,16 @@ public class DefaultDataType<T> extends AbstractDataTypeX<T> {
return P_NORMALISE.matcher(typeName.toUpperCase()).replaceAll("");
}
/**
* @return The type name without all special characters and white spaces
*/
static final String normalise(SQLDialect dialect, String typeName) {
if (dialect != null && dialect.family() == CLICKHOUSE && typeName.startsWith("Nullable("))
typeName = P_NULLABLE.matcher(typeName).replaceFirst(r -> r.group(1));
return normalise(typeName);
}
/**
* Convert a type name (using precision and scale) into a Java class
*/

View File

@ -191,6 +191,12 @@ final class SQLDataTypes {
static final DataType<UInteger> UINT32 = new BuiltInDataType<>(FAMILY, SQLDataType.INTEGERUNSIGNED, "UInt32");
static final DataType<ULong> UINT64 = new BuiltInDataType<>(FAMILY, SQLDataType.BIGINTUNSIGNED, "UInt64");
// -------------------------------------------------------------------------
// Dialect-specific data types and synonyms thereof
// -------------------------------------------------------------------------
static final DataType<Object> NOTHING = new BuiltInDataType<>(FAMILY, SQLDataType.OTHER, "Nothing");
// -------------------------------------------------------------------------
// Compatibility types for supported SQLDialect.CLICKHOUSE, SQLDataTypes
// -------------------------------------------------------------------------