Skip to content

Add parser support for aggregate functions #5

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

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

writemorecode
Copy link
Owner

Adds parser support for aggregate functions: SUM, AVG, STDDEV, MIN, MAX, COUNT.

SUM, AVG, STDDEV, MIN, MAX, COUNT
@writemorecode writemorecode requested a review from Copilot June 2, 2025 18:01
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds parser support for aggregate functions (SUM, AVG, STDDEV, MIN, MAX, COUNT) to the SQL parser. Key changes include updating test files to cover aggregate functions, extending the parser to handle new aggregate function tokens, and updating token kind definitions to support aggregate-specific keywords.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/databas_sql_parser/tests/parse_select.rs Updated test import to support the new AggregateFunction variant
crates/databas_sql_parser/tests/parse_aggregate.rs Added new tests covering all aggregate functions
crates/databas_sql_parser/src/parser/mod.rs Introduced parse_aggregate_function and integrated it into expression parsing
crates/databas_sql_parser/src/parser/expr.rs Added AggregateFunction variant to the Expression enum and Display implementation
crates/databas_sql_parser/src/lexer/token_kind.rs Extended Keyword enum and token parsing to recognize aggregate keywords
Comments suppressed due to low confidence (2)

crates/databas_sql_parser/tests/parse_aggregate.rs:12

  • Consider adding negative tests to verify that incorrect aggregate function syntax (e.g. missing parentheses or unsupported tokens) is handled properly by the parser.
fn test_all_aggregate_functions() {

crates/databas_sql_parser/src/parser/mod.rs:166

  • [nitpick] The parameter name 'agg' could be made more descriptive (for example, 'aggregate_token') to improve code readability.
TokenKind::Keyword(Keyword::Aggregate(agg)) => self.parse_aggregate_function(agg)?,

@writemorecode writemorecode merged commit b1334bb into main Jun 2, 2025
1 check passed
@writemorecode writemorecode deleted the feat/parser_sum_function branch June 2, 2025 18:04
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.

1 participant