[jOOQ/jOOQ#14402] Add support for Databricks SQL - WIP
This commit is contained in:
parent
e8a43a7352
commit
78afbdfe12
@ -699,10 +699,6 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else
|
||||
return castTypePrefix0() + "(" + length() + ")" + castTypeSuffix0();
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ implements
|
||||
}
|
||||
}
|
||||
|
||||
private final void acceptDefault(Context<?> ctx) {
|
||||
final void acceptDefault(Context<?> ctx) {
|
||||
ctx.sql("(")
|
||||
.visit(wrap(fields.fields))
|
||||
.sql(")");
|
||||
|
||||
@ -258,6 +258,8 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private final Table<?> table;
|
||||
private final boolean ifExists;
|
||||
private boolean ifExistsColumn;
|
||||
@ -1787,6 +1789,7 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
case CLICKHOUSE:
|
||||
case TRINO:
|
||||
ctx.visit(K_DROP_COLUMN);
|
||||
|
||||
@ -188,6 +188,10 @@ implements
|
||||
private static final Set<SQLDialect> NO_SUPPORT_IF_EXISTS = SQLDialect.supportedUntil(CUBRID, DERBY, FIREBIRD);
|
||||
private static final Set<SQLDialect> SUPPORT_ALTER_TABLE_RENAME = SQLDialect.supportedBy(CLICKHOUSE, HSQLDB, YUGABYTEDB);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private final boolean supportsIfExists(Context<?> ctx) {
|
||||
if (renameTo != null)
|
||||
return !NO_SUPPORT_RENAME_IF_EXISTS.contains(ctx.dialect());
|
||||
@ -250,11 +254,18 @@ implements
|
||||
ctx.visit(K_MATERIALIZED).sql(' ');
|
||||
|
||||
ctx.visit(K_VIEW).sql(' ').visit(view);
|
||||
Select<?> s = as;
|
||||
|
||||
if (!fields.isEmpty()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!fields.isEmpty())
|
||||
ctx.sql(" (").visit(QueryPartCollectionView.wrap(fields).qualify(false)).sql(')');
|
||||
}
|
||||
|
||||
ctx.formatSeparator().visit(K_AS).formatSeparator().visit(as);
|
||||
ctx.formatSeparator().visit(K_AS).formatSeparator().visit(s);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -171,6 +171,14 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -274,6 +282,7 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private final void acceptMySQL(Context<?> ctx) {
|
||||
|
||||
@ -79,6 +79,7 @@ final class CountTable extends AbstractAggregateFunction<Integer> implements QOM
|
||||
|
||||
|
||||
|
||||
|
||||
case CLICKHOUSE:
|
||||
case CUBRID:
|
||||
case DERBY:
|
||||
|
||||
@ -497,6 +497,15 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctx.end(Clause.CREATE_TABLE);
|
||||
}
|
||||
|
||||
|
||||
@ -293,13 +293,17 @@ implements
|
||||
// [#4806] CREATE VIEW doesn't accept parameters in most databases
|
||||
.visit(
|
||||
rename && !renameSupported
|
||||
? selectFrom(parsed().asTable(name("t"), map(f, Field::getUnqualifiedName, Name[]::new)))
|
||||
? renameSelect(parsed(), f)
|
||||
: query,
|
||||
ParamType.INLINED
|
||||
)
|
||||
.end(Clause.CREATE_VIEW_AS);
|
||||
}
|
||||
|
||||
static final Select<?> renameSelect(Select<?> s, List<? extends Field<?>> f) {
|
||||
return selectFrom(s.asTable(name("t"), map(f, Field::getUnqualifiedName, Name[]::new)));
|
||||
}
|
||||
|
||||
final Select<?> parsed() {
|
||||
if (parsed != null)
|
||||
return parsed;
|
||||
|
||||
@ -232,6 +232,7 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case TRINO:
|
||||
@ -415,6 +416,7 @@ final class FieldMapsForInsert extends AbstractQueryPart implements UNotYetImple
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// See https://github.com/trinodb/trino/issues/10161
|
||||
|
||||
@ -75,6 +75,7 @@ import java.util.Set;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.GroupField;
|
||||
import org.jooq.Row;
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.UniqueKey;
|
||||
@ -130,6 +131,11 @@ final class GroupFieldList extends QueryPartList<GroupField> {
|
||||
else
|
||||
super.acceptElement(ctx, part);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else
|
||||
super.acceptElement(ctx, part);
|
||||
}
|
||||
|
||||
@ -53,6 +53,7 @@ import static org.jooq.Clause.INSERT_RETURNING;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.DUCKDB;
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
@ -75,7 +76,6 @@ import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.ConditionProviderImpl.extractCondition;
|
||||
import static org.jooq.impl.DSL.constraint;
|
||||
import static org.jooq.impl.DSL.default_;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.selectFrom;
|
||||
@ -119,8 +119,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@ -1690,6 +1690,7 @@ final class Interpreter {
|
||||
|
||||
|
||||
|
||||
|
||||
case DUCKDB:
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
|
||||
@ -58,6 +58,7 @@ import static org.jooq.SQLDialect.CLICKHOUSE;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.CUBRID;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.DERBY;
|
||||
import static org.jooq.SQLDialect.DUCKDB;
|
||||
// ...
|
||||
@ -84,13 +85,10 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
import static org.jooq.SQLDialect.TRINO;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.YUGABYTEDB;
|
||||
import static org.jooq.conf.WriteIfReadonly.IGNORE;
|
||||
import static org.jooq.conf.WriteIfReadonly.THROW;
|
||||
import static org.jooq.impl.ConditionProviderImpl.extractCondition;
|
||||
import static org.jooq.impl.DSL.condition;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.field;
|
||||
import static org.jooq.impl.DSL.insertInto;
|
||||
import static org.jooq.impl.DSL.noCondition;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
import static org.jooq.impl.DSL.trueCondition;
|
||||
@ -100,7 +98,6 @@ import static org.jooq.impl.Keywords.K_AS;
|
||||
import static org.jooq.impl.Keywords.K_BY;
|
||||
import static org.jooq.impl.Keywords.K_DELETE;
|
||||
import static org.jooq.impl.Keywords.K_INSERT;
|
||||
import static org.jooq.impl.Keywords.K_KEY;
|
||||
import static org.jooq.impl.Keywords.K_MATCHED;
|
||||
import static org.jooq.impl.Keywords.K_MERGE_INTO;
|
||||
import static org.jooq.impl.Keywords.K_NOT;
|
||||
@ -110,28 +107,19 @@ import static org.jooq.impl.Keywords.K_SOURCE;
|
||||
import static org.jooq.impl.Keywords.K_TARGET;
|
||||
import static org.jooq.impl.Keywords.K_THEN;
|
||||
import static org.jooq.impl.Keywords.K_UPDATE;
|
||||
import static org.jooq.impl.Keywords.K_UPSERT;
|
||||
import static org.jooq.impl.Keywords.K_USING;
|
||||
import static org.jooq.impl.Keywords.K_VALUES;
|
||||
import static org.jooq.impl.Keywords.K_WHEN;
|
||||
import static org.jooq.impl.Keywords.K_WHERE;
|
||||
import static org.jooq.impl.Keywords.K_WITH_PRIMARY_KEY;
|
||||
import static org.jooq.impl.QueryPartListView.wrap;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.collect;
|
||||
import static org.jooq.impl.Tools.concat;
|
||||
import static org.jooq.impl.Tools.filter;
|
||||
import static org.jooq.impl.Tools.isEmpty;
|
||||
import static org.jooq.impl.Tools.map;
|
||||
import static org.jooq.impl.Tools.nullSafe;
|
||||
import static org.jooq.impl.Tools.BooleanDataKey.DATA_WRAP_DERIVED_TABLES_IN_PARENTHESES;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -212,10 +200,7 @@ import org.jooq.SelectField;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.TableLike;
|
||||
// ...
|
||||
import org.jooq.UniqueKey;
|
||||
import org.jooq.exception.DataTypeException;
|
||||
import org.jooq.impl.FieldMapForUpdate.SetClause;
|
||||
import org.jooq.impl.QOM.Insert;
|
||||
import org.jooq.impl.QOM.Merge;
|
||||
import org.jooq.impl.QOM.MergeMatched;
|
||||
import org.jooq.impl.QOM.MergeNotMatched;
|
||||
@ -223,15 +208,11 @@ import org.jooq.impl.QOM.MergeNotMatchedBySource;
|
||||
import org.jooq.impl.QOM.UNotYetImplemented;
|
||||
import org.jooq.impl.QOM.UnmodifiableList;
|
||||
import org.jooq.impl.QOM.UnmodifiableMap;
|
||||
import org.jooq.impl.QOM.Update;
|
||||
import org.jooq.impl.QOM.With;
|
||||
import org.jooq.impl.Tools.ExtendedDataKey;
|
||||
import org.jooq.tools.JooqLogger;
|
||||
import org.jooq.tools.StringUtils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* The SQL standard MERGE statement
|
||||
*
|
||||
|
||||
@ -579,6 +579,17 @@ final class MetaImpl extends AbstractMeta {
|
||||
switch (dsl().family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case MYSQL:
|
||||
case MARIADB: {
|
||||
|
||||
@ -1054,7 +1065,7 @@ final class MetaImpl extends AbstractMeta {
|
||||
name(name),
|
||||
schema,
|
||||
null, (ForeignKey<?, Record>) null, (InverseForeignKey<?, Record>) null, null, null,
|
||||
comment(remarks != null ? remarks : schema.comment(name, null)),
|
||||
comment(remarks != null ? remarks : schema.comment(name)),
|
||||
tableOption(dsl(), schema, name, tableType),
|
||||
null
|
||||
);
|
||||
@ -1558,6 +1569,14 @@ final class MetaImpl extends AbstractMeta {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -135,6 +135,7 @@ final class MetaSQL {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
M_SEQUENCES.put(DERBY, "select cast(null as varchar(32672)) as catalog, SYS.SYSSCHEMAS.SCHEMANAME, SYS.SYSSEQUENCES.SEQUENCENAME, SYS.SYSSEQUENCES.SEQUENCEDATATYPE, cast(null as int) as numeric_precision, cast(null as int) as numeric_scale, nullif(SYS.SYSSEQUENCES.STARTVALUE, 1) as STARTVALUE, nullif(SYS.SYSSEQUENCES.INCREMENT, 1) as INCREMENT, nullif(SYS.SYSSEQUENCES.MINIMUMVALUE, case when cast(SYS.SYSSEQUENCES.SEQUENCEDATATYPE as varchar(32672)) = 'SMALLINT' then -32768 when cast(SYS.SYSSEQUENCES.SEQUENCEDATATYPE as varchar(32672)) = 'INTEGER' then -2147483648 when cast(SYS.SYSSEQUENCES.SEQUENCEDATATYPE as varchar(32672)) = 'BIGINT' then -9223372036854775808 end) as MINIMUMVALUE, nullif(SYS.SYSSEQUENCES.MAXIMUMVALUE, case when cast(SYS.SYSSEQUENCES.SEQUENCEDATATYPE as varchar(32672)) = 'SMALLINT' then 32767 when cast(SYS.SYSSEQUENCES.SEQUENCEDATATYPE as varchar(32672)) = 'INTEGER' then 2147483647 when cast(SYS.SYSSEQUENCES.SEQUENCEDATATYPE as varchar(32672)) = 'BIGINT' then 9223372036854775807 end) as MAXIMUMVALUE, (SYS.SYSSEQUENCES.CYCLEOPTION = 'Y') as CYCLEOPTION, cast(null as bigint) as cache from SYS.SYSSEQUENCES join SYS.SYSSCHEMAS on SYS.SYSSEQUENCES.SCHEMAID = SYS.SYSSCHEMAS.SCHEMAID where cast(SYS.SYSSCHEMAS.SCHEMANAME as varchar(32672)) in (cast(? as varchar(32672))) order by SYS.SYSSCHEMAS.SCHEMANAME, SYS.SYSSEQUENCES.SEQUENCENAME");
|
||||
@ -368,6 +369,7 @@ final class MetaSQL {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
M_COMMENTS.put(CLICKHOUSE, "select c.catalog, c.database, c.table, c.name, c.comment from (select system.tables.database catalog, system.tables.database, system.tables.name table, null name, system.tables.comment comment from system.tables where system.tables.comment <> '' union all select system.columns.database catalog, system.columns.database, system.columns.table, system.columns.name, system.columns.comment from system.columns where system.columns.comment <> '') c where c.database in (?) order by 1, 2, 3, 4");
|
||||
@ -525,6 +527,7 @@ final class MetaSQL {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -89,6 +89,7 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
case FIREBIRD:
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user