[#5955] Support DISTINCT ON
This commit is contained in:
parent
b3e55d5cea
commit
99d25ea784
@ -642,12 +642,21 @@ class ParserImpl implements Parser {
|
||||
|
||||
parseKeyword(ctx, "SELECT");
|
||||
boolean distinct = parseKeywordIf(ctx, "DISTINCT") || parseKeywordIf(ctx, "UNIQUE");
|
||||
List<Field<?>> distinctOn = null;
|
||||
|
||||
if (distinct) {
|
||||
if (parseKeywordIf(ctx, "ON")) {
|
||||
parse(ctx, '(');
|
||||
distinctOn = parseFields(ctx);
|
||||
parse(ctx, ')');
|
||||
}
|
||||
}
|
||||
else
|
||||
parseKeywordIf(ctx, "ALL");
|
||||
|
||||
Long limit = null;
|
||||
Long offset = null;
|
||||
|
||||
if (!distinct)
|
||||
parseKeywordIf(ctx, "ALL");
|
||||
|
||||
// T-SQL style TOP .. START AT
|
||||
if (parseKeywordIf(ctx, "TOP")) {
|
||||
limit = parseUnsignedInteger(ctx);
|
||||
@ -753,6 +762,9 @@ class ParserImpl implements Parser {
|
||||
if (distinct)
|
||||
result.setDistinct(distinct);
|
||||
|
||||
if (distinctOn != null)
|
||||
result.addDistinctOn(distinctOn);
|
||||
|
||||
if (select.size() > 0)
|
||||
result.addSelect(select);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user