[jOOQ/jOOQ#14653] Add SQL/JSON support for the SNOWFLAKE dialect

This commit is contained in:
Lukas Eder 2023-02-16 15:58:50 +01:00
parent e6937784f9
commit b463c3784e
10 changed files with 578 additions and 501 deletions

View File

@ -45,6 +45,7 @@ import org.jetbrains.annotations.*;
import static org.jooq.SQLDialect.H2;
// ...
import static org.jooq.SQLDialect.POSTGRES;
// ...
import static org.jooq.SQLDialect.SQLITE;
import static org.jooq.SQLDialect.YUGABYTEDB;

View File

@ -47,6 +47,7 @@ import static org.jooq.SQLDialect.H2;
import static org.jooq.SQLDialect.MARIADB;
// ...
import static org.jooq.SQLDialect.POSTGRES;
// ...
import static org.jooq.SQLDialect.YUGABYTEDB;
import java.util.Collection;

View File

@ -45,8 +45,10 @@ import static org.jooq.SQLDialect.MARIADB;
import static org.jooq.SQLDialect.MYSQL;
// ...
import static org.jooq.SQLDialect.POSTGRES;
// ...
import static org.jooq.SQLDialect.SQLITE;
// ...
// ...
import static org.jooq.SQLDialect.YUGABYTEDB;
import org.jetbrains.annotations.NotNull;

View File

@ -183,6 +183,13 @@ implements

View File

@ -49,6 +49,7 @@ import static org.jooq.impl.DSL.inline;
import static org.jooq.impl.JSONEntryImpl.jsonCastMapper;
import static org.jooq.impl.JSONEntryImpl.jsonMerge;
import static org.jooq.impl.Keywords.K_DISTINCT;
import static org.jooq.impl.Names.N_ARRAY_AGG;
import static org.jooq.impl.Names.N_GROUP_CONCAT;
import static org.jooq.impl.Names.N_JSONB_AGG;
import static org.jooq.impl.Names.N_JSON_AGG;
@ -66,7 +67,6 @@ import static org.jooq.impl.Tools.BooleanDataKey.DATA_FORCE_CASE_ELSE_NULL;
import java.util.Collection;
import java.util.Set;
import org.jooq.AggregateFunction;
import org.jooq.Context;
import org.jooq.DataType;
import org.jooq.Field;
@ -129,6 +129,15 @@ implements

View File

@ -161,6 +161,7 @@ final class JSONEntryImpl<T> extends AbstractQueryPart implements JSONEntry<T>,
case MARIADB:

View File

@ -180,6 +180,14 @@ implements

File diff suppressed because it is too large Load Diff

View File

@ -8486,6 +8486,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return parseFunctionArgs2((f1, f2) -> arrayAppend((Field<Void[]>) f1, (Field<Void>) f2));
else if (parseFunctionNameIf("ARRAY_PREPEND"))
return parseFunctionArgs2((f1, f2) -> arrayPrepend((Field<Void>) f1, (Field<Void[]>) f2));
else if ((field = parseFieldArrayConstructIf()) != null)
return field;
break;
@ -8870,9 +8872,10 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return field;
else if ((field = parseFieldTranslateIf()) != null)
return field;
else if (parseFunctionNameIf("OCTET_LENGTH"))
return octetLength((Field) parseFieldParenthesised());
else if ((field = parseFieldObjectConstructIf()) != null)
return field;
break;
@ -9973,6 +9976,42 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
parse(')');
return result;
}
return null;
}
private final Field<?> parseFieldArrayConstructIf() {
boolean absentOnNull = false;
if ((parseFunctionNameIf("ARRAY_CONSTRUCT") || (absentOnNull = parseFunctionNameIf("ARRAY_CONSTRUCT_COMPACT")) && requireProEdition())) {
}
return null;
}
private final Field<?> parseFieldObjectConstructIf() {
boolean nullOnNull = false;
if ((parseFunctionNameIf("OBJECT_CONSTRUCT") || (nullOnNull = parseFunctionNameIf("OBJECT_CONSTRUCT_KEEP_NULL")) && requireProEdition())) {
}
return null;
@ -10049,10 +10088,14 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
}
private final JSONEntry<?> parseJSONEntry() {
boolean valueRequired = parseKeywordIf("KEY");
return parseJSONEntry(true);
}
private final JSONEntry<?> parseJSONEntry(boolean supportKeyValue) {
boolean valueRequired = supportKeyValue && parseKeywordIf("KEY");
Field<String> key = (Field<String>) parseField();
if (parseKeywordIf("VALUE"))
if (supportKeyValue && parseKeywordIf("VALUE"))
;
else if (valueRequired)
throw expected("VALUE");

View File

@ -6848,6 +6848,7 @@ final class Tools {
case YUGABYTEDB:
return NestedCollectionEmulation.JSONB;
case H2:
case MARIADB:
case MYSQL: