[jOOQ/jOOQ#19314] Use ARRAY_AGG emulation for BigQuery MIN_BY() or MAX_BY() window function
This commit is contained in:
parent
4e46e252ca
commit
9840750a0e
@ -127,6 +127,15 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -141,29 +150,37 @@ implements
|
||||
case HSQLDB:
|
||||
case POSTGRES:
|
||||
case YUGABYTEDB: {
|
||||
List<SortField<?>> o = new ArrayList<>();
|
||||
o.add(arguments.get(1).desc());
|
||||
|
||||
if (!isEmpty(withinGroupOrderBy))
|
||||
o.addAll(withinGroupOrderBy);
|
||||
|
||||
ctx.visit(arrayGet(fo(DSL.arrayAgg(arguments.get(0)).orderBy(o)), inline(1)));
|
||||
acceptArrayAggEmulation(ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
acceptFunctionName(ctx);
|
||||
ctx.sql('(');
|
||||
acceptArguments0(ctx);
|
||||
acceptOrderBy(ctx);
|
||||
ctx.sql(')');
|
||||
|
||||
acceptFilterClause(ctx);
|
||||
acceptOverClause(ctx);
|
||||
acceptDefault(ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private final void acceptArrayAggEmulation(Context<?> ctx) {
|
||||
List<SortField<?>> o = new ArrayList<>();
|
||||
o.add(arguments.get(1).desc());
|
||||
|
||||
if (!isEmpty(withinGroupOrderBy))
|
||||
o.addAll(withinGroupOrderBy);
|
||||
|
||||
ctx.visit(arrayGet(fo(DSL.arrayAgg(arguments.get(0)).orderBy(o)), inline(1)));
|
||||
}
|
||||
|
||||
private final void acceptDefault(Context<?> ctx) {
|
||||
acceptFunctionName(ctx);
|
||||
ctx.sql('(');
|
||||
acceptArguments0(ctx);
|
||||
acceptOrderBy(ctx);
|
||||
ctx.sql(')');
|
||||
|
||||
acceptFilterClause(ctx);
|
||||
acceptOverClause(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
final void acceptFunctionName(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
@ -127,6 +127,15 @@ implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -141,29 +150,37 @@ implements
|
||||
case HSQLDB:
|
||||
case POSTGRES:
|
||||
case YUGABYTEDB: {
|
||||
List<SortField<?>> o = new ArrayList<>();
|
||||
o.add(arguments.get(1).sortDefault());
|
||||
|
||||
if (!isEmpty(withinGroupOrderBy))
|
||||
o.addAll(withinGroupOrderBy);
|
||||
|
||||
ctx.visit(arrayGet(fo(DSL.arrayAgg(arguments.get(0)).orderBy(o)), inline(1)));
|
||||
acceptArrayAggEmulation(ctx);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
acceptFunctionName(ctx);
|
||||
ctx.sql('(');
|
||||
acceptArguments0(ctx);
|
||||
acceptOrderBy(ctx);
|
||||
ctx.sql(')');
|
||||
|
||||
acceptFilterClause(ctx);
|
||||
acceptOverClause(ctx);
|
||||
acceptDefault(ctx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private final void acceptArrayAggEmulation(Context<?> ctx) {
|
||||
List<SortField<?>> o = new ArrayList<>();
|
||||
o.add(arguments.get(1).sortDefault());
|
||||
|
||||
if (!isEmpty(withinGroupOrderBy))
|
||||
o.addAll(withinGroupOrderBy);
|
||||
|
||||
ctx.visit(arrayGet(fo(DSL.arrayAgg(arguments.get(0)).orderBy(o)), inline(1)));
|
||||
}
|
||||
|
||||
private final void acceptDefault(Context<?> ctx) {
|
||||
acceptFunctionName(ctx);
|
||||
ctx.sql('(');
|
||||
acceptArguments0(ctx);
|
||||
acceptOrderBy(ctx);
|
||||
ctx.sql(')');
|
||||
|
||||
acceptFilterClause(ctx);
|
||||
acceptOverClause(ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
final void acceptFunctionName(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user