Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse error with GROUPING soql function #49

Closed
adangel opened this issue Aug 29, 2024 · 1 comment · Fixed by #50
Closed

Parse error with GROUPING soql function #49

adangel opened this issue Aug 29, 2024 · 1 comment · Fixed by #50

Comments

@adangel
Copy link
Contributor

adangel commented Aug 29, 2024

Example code:

public class MyClassA3 {
    private List<AggregateResult> getDefects() {
        AggregateResult[] defects = [
            SELECT
              OBJ1__c O1,
              OBJ2__c O2,
              OBJ3__c O3,
              SUM(OBJ4__c) O4,
              GROUPING(OBJ1__c) O1Group,
              GROUPING(OBJ2__c) O2Group,
              GROUPING(OBJ3__c) O3Group
            FROM OBJ4__c
            GROUP BY ROLLUP(OBJ1__c, OBJ2__c, OBJ3__c)
        ];
        return defects;
    }
}

This fails to parse, as GROUPING is not supported by the grammar:

soqlFunction
: AVG LPAREN fieldName RPAREN
| COUNT LPAREN RPAREN
| COUNT LPAREN fieldName RPAREN
| COUNT_DISTINCT LPAREN fieldName RPAREN
| MIN LPAREN fieldName RPAREN
| MAX LPAREN fieldName RPAREN
| SUM LPAREN fieldName RPAREN
| TOLABEL LPAREN fieldName RPAREN
| FORMAT LPAREN fieldName RPAREN
| CALENDAR_MONTH LPAREN dateFieldName RPAREN
| CALENDAR_QUARTER LPAREN dateFieldName RPAREN
| CALENDAR_YEAR LPAREN dateFieldName RPAREN
| DAY_IN_MONTH LPAREN dateFieldName RPAREN
| DAY_IN_WEEK LPAREN dateFieldName RPAREN
| DAY_IN_YEAR LPAREN dateFieldName RPAREN
| DAY_ONLY LPAREN dateFieldName RPAREN
| FISCAL_MONTH LPAREN dateFieldName RPAREN
| FISCAL_QUARTER LPAREN dateFieldName RPAREN
| FISCAL_YEAR LPAREN dateFieldName RPAREN
| HOUR_IN_DAY LPAREN dateFieldName RPAREN
| WEEK_IN_MONTH LPAREN dateFieldName RPAREN
| WEEK_IN_YEAR LPAREN dateFieldName RPAREN
| FIELDS LPAREN soqlFieldsParameter RPAREN
| DISTANCE LPAREN locationValue COMMA locationValue COMMA StringLiteral RPAREN
;

sf doc: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_grouping.htm

Original issue: pmd/pmd#5182

@pwrightcertinia
Copy link
Contributor

Thank you for the contribution! Now released in version 4.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@adangel @pwrightcertinia and others