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

Remove hard-coded aggregations within the AST #1460

Closed
alancai98 opened this issue May 8, 2024 · 2 comments
Closed

Remove hard-coded aggregations within the AST #1460

alancai98 opened this issue May 8, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request public API

Comments

@alancai98
Copy link
Member

There are several places within the partiql-parser and partiql-ast where we specify dedicated aggregation rules and nodes.

In the ANTLR grammar:

aggregate
: func=COUNT PAREN_LEFT ASTERISK PAREN_RIGHT # CountAll
| func=(COUNT|MAX|MIN|SUM|AVG|EVERY|ANY|SOME) PAREN_LEFT setQuantifierStrategy? expr PAREN_RIGHT # AggregateBase
;

A couple problems w/ above:

  • Aggregate function names are hard-coded
  • Designated aggregate rule -- perhaps can be consolidated with the existing function call rule

In the partiql-ast:

// Aggregate Function Call
agg::{
function: identifier,
args: list::[expr],
setq: optional::set_quantifier,
},

Similar issue to above.

To allow for aggregate UDFs in the future, we should not distinguish between the aggregate and scalar functions till planning time. This will require modification of the AST to plan conversion code, which currently assumes the resolution occurs during parsing.

@alancai98 alancai98 added enhancement New feature or request public API labels May 8, 2024
@alancai98
Copy link
Member Author

This task can be broken down into multiple components:

  1. removing hard-coded aggregate functions from AST + parser
  2. figuring out scalar vs aggregation resolution in the planner. As a temporary workaround, could hard-code the logic in the AST to plan code. A future PR could integrate this resolution w/ the SPI + connector metadata interfaces.
  3. (future) creating a UDF aggregation function -- might require further specification. E.g. name conflicts between scalar and aggregate functions.

@alancai98
Copy link
Member Author

Resolved by #1464.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request public API
Projects
None yet
Development

No branches or pull requests

1 participant