Skip to content

Select Distinct support in JSON query - #103

Merged
robinskil merged 3 commits into
mainfrom
features/distinct-select
Oct 31, 2025
Merged

robinskil merged 3 commits into
mainfrom
features/distinct-select

Conversation

@robinskil

Copy link
Copy Markdown
Collaborator

This pull request updates the handling of the distinct field in query requests, enabling support for more advanced distinct queries by introducing a new Distinct struct. The changes also update the query planning logic to use this new structure, allowing for distinct operations on specific columns with custom select expressions.

Distinct query support:

  • Changed the distinct field in QueryBody from an Option<Vec<String>> to an Option<Distinct>, and introduced a new Distinct struct with on and select fields to specify which columns to apply distinct on and which columns to select. (beacon-query/src/lib.rs)
  • Updated the query planning logic to use the new Distinct struct: now, if a distinct clause is present, the planner builds expressions for both the on and select fields, and applies them using distinct_on. (beacon-query/src/parser.rs)

Code cleanup:

  • Removed unused imports from beacon-query/src/parser.rs for clarity and maintainability.

Minor fix:

  • Fixed the way the schema is passed to filter parsing functions for consistency. (beacon-query/src/parser.rs)

@robinskil robinskil self-assigned this Oct 20, 2025
Copilot AI review requested due to automatic review settings October 20, 2025 12:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request enhances the query system to support more advanced distinct operations by replacing the simple string-based distinct field with a structured approach. The changes enable specifying both the columns to apply distinct on and the columns to select, providing greater flexibility for distinct queries.

  • Introduced a new Distinct struct with on and select fields to replace the simple Vec<String> distinct field
  • Updated query planning logic to handle the new distinct structure using distinct_on operations
  • Cleaned up unused imports and fixed schema parameter passing consistency

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
beacon-query/src/lib.rs Introduces the new Distinct struct and updates QueryBody to use it instead of Vec<String>
beacon-query/src/parser.rs Updates query planning logic to handle the new distinct structure, removes unused imports, and fixes schema parameter passing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +117 to +127
let on_exprs = distinct
.on
.iter()
.map(|s| s.to_expr(&session.state()))
.collect::<anyhow::Result<Vec<_>>>()?;

let select_exprs = distinct
.select
.iter()
.map(|s| s.to_expr(&session.state()))
.collect::<anyhow::Result<Vec<_>>>()?;

Copilot AI Oct 20, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The repeated pattern of mapping to_expr(&session.state()) and collecting results could be extracted into a helper function to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
@robinskil
robinskil merged commit a83220b into main Oct 31, 2025
1 check passed
@robinskil robinskil mentioned this pull request Nov 9, 2025
@robinskil
robinskil deleted the features/distinct-select branch December 8, 2025 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants