Skip to content

Conversation

R3gardless
Copy link
Contributor

@R3gardless R3gardless commented Oct 14, 2024

Brief summary of the change made

Support for parsing ALTER AGGREGATE statements in PostgreSQL.

Are there any other side effects of this change that we should be aware of?

None

Pull Request checklist

  • Please confirm you have completed any of the necessary steps below.

  • Included test cases to demonstrate any code changes, which may be one or more of the following:

    • .yml rule test cases in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
ALTER AGGREGATE range_agg_preserve_gaps (TSTZRANGE) RENAME TO my_agg;

ALTER AGGREGATE my_agg (TSTZRANGE) OWNER TO me;
ALTER AGGREGATE my_agg (TSTZRANGE) OWNER TO CURRENT_ROLE;
ALTER AGGREGATE my_agg (TSTZRANGE) OWNER TO CURRENT_USER;
ALTER AGGREGATE my_agg (TSTZRANGE) OWNER TO SESSION_USER;

ALTER AGGREGATE my_agg (*) SET SCHEMA api;

ALTER AGGREGATE complex_agg_function(integer, text, numeric)
RENAME TO renamed_agg_function;
  • Full autofix test cases in test/fixtures/linter/autofix.
  • Other.
  • Added appropriate documentation for the change.
  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

Copy link
Contributor

github-actions bot commented Oct 14, 2024

Coverage Results ✅

Name    Stmts   Miss  Cover   Missing
-------------------------------------
TOTAL   18586      0   100%

236 files skipped due to complete coverage.

@R3gardless
Copy link
Contributor Author

When looking at the code, both DropAggregateStatementSegment and CreateAggregateStatementSegment use ObjectReferenceSegment, but I'm not sure if it should be FunctionNameSegment instead. Which one is correct?

@alanmcruickshank
Copy link
Member

alanmcruickshank commented Oct 14, 2024

When looking at the code, both DropAggregateStatementSegment and CreateAggregateStatementSegment use ObjectReferenceSegment, but I'm not sure if it should be FunctionNameSegment instead. Which one is correct?

Good question....

...I would probably say use ObjectReferenceSegment, because we're referring to the function as an object, rather than calling it as a segment. But I think I'd be persuadable. Whichever you choose - it should be consistent. Either we use ObjectReferenceSegment here, or we update all the others to use FunctionNameSegment.

@R3gardless
Copy link
Contributor Author

R3gardless commented Oct 15, 2024

Thanks for the reply.
I’m not very familiar with the inner architecture of PostgreSQL. If an Aggregate Function objects wraps a Function objects, I would prefer using ObjectReferenceSegment. Otherwise, I think using FunctionNameSegment would be better.

@R3gardless
Copy link
Contributor Author

R3gardless commented Oct 16, 2024

@alanmcruickshank I've decided to use ObjectReferenceSegment because I'm not entirely sure if FunctionNameSegment is the better option.

Copy link
Member

@alanmcruickshank alanmcruickshank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the edit. I think it's probably the right call for now.

@alanmcruickshank alanmcruickshank added this pull request to the merge queue Oct 16, 2024
Merged via the queue into sqlfluff:main with commit e21abac Oct 16, 2024
28 checks passed
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 this pull request may close these issues.

[postgres] aggregate DDL: unparseable section
2 participants