Skip to content

[SQL] Support for range aggregates sorting on intervals, booleans#6310

Merged
mihaibudiu merged 1 commit into
feldera:mainfrom
mihaibudiu:sort-bool
May 27, 2026
Merged

[SQL] Support for range aggregates sorting on intervals, booleans#6310
mihaibudiu merged 1 commit into
feldera:mainfrom
mihaibudiu:sort-bool

Conversation

@mihaibudiu

@mihaibudiu mihaibudiu commented May 24, 2026

Copy link
Copy Markdown
Contributor

Part of #457

Range aggregates use radix-sort on unsigned values up to 128 bits. Any other type must be converted back and forth to some unsigned type (including the NULL value if the type is nullable). This PR adds support for BOOL, short and long intervals.

Checklist

  • Unit tests added/updated

@mythical-fred mythical-fred left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Two real findings worth fixing inline; rest are nits. The NULLS FIRST sub-cases in issue457b/c don't actually exercise NULLS FIRST (no-op string replace), so the new nullable-interval radix-sort path is only covered by the default ordering. Otherwise the wiring looks consistent with the existing INTERVAL/UUID pattern.

Comment thread crates/sqllib/src/error.rs

#[doc(hidden)]
#[inline(always)]
pub fn wrap_bool(b: Option<bool>) -> bool {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

many of these functions were moved from lib.rs

@mihaibudiu mihaibudiu requested a review from gz May 25, 2026 00:53
@mihaibudiu mihaibudiu enabled auto-merge May 25, 2026 00:54

@mythical-fred mythical-fred left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Quick follow-up after the force-push. Most of my prior nits are addressed (the HOURS/MONTHS replace targets now actually match the program text, the five-digit-year typo is gone, the LONG_INTERVAL_TO_INTEGER comment is correct). Two from last round are still live:

  • issue457c NULLS FIRST sub-case is still a no-op (replace target doesn't match program text).
  • error.rs: from_strng typo and the "NULL result produced" message survived. These are now on the hot path for nullable BOOL/INTERVAL range aggs, so worth a once-over.

Nothing here blocks the behaviour change; tests cover the substantive new code paths.

var ccs = this.getCCS(program);
ccs.stepWeightOne(data, expected);

var program1 = program.replace("ORDER BY seq", "ORDER BY seq NULLS FIRST");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same issue I flagged last round, still here: this program's ORDER BY clause is ORDER BY (d1 - d2) MONTHS, not ORDER BY seq. The replace is a no-op and the NULLS-FIRST sub-case silently re-runs the default-ordering case. The MONTHS -> MONTHS NULLS LAST substitution on line 281 is the correct shape; line 277 should follow suit (MONTHS -> MONTHS NULLS FIRST).

pub fn unwrap_sql_result<T>(data: SqlResult<Option<T>>) -> SqlResult<T> {
match data {
Err(e) => Err(e),
Ok(None) => Err(SqlRuntimeError::from_strng("NULL result produced")),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Re-flagging from last round (not a blocker): from_strng is a typo for from_string, and "NULL result produced" is non-actionable for end users now that nullable BOOL/INTERVAL ordering routes through here. Worth tightening the message (which SQL op, or at least "NULL result in non-nullable context") while we're in the area.

@mihaibudiu mihaibudiu added this pull request to the merge queue May 25, 2026

@mythical-fred mythical-fred left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM — all prior findings addressed.

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 26, 2026
@mihaibudiu mihaibudiu force-pushed the sort-bool branch 2 times, most recently from 39ddf8b to 6196492 Compare May 26, 2026 03:59
@mihaibudiu mihaibudiu enabled auto-merge May 26, 2026 03:59
@mihaibudiu mihaibudiu added this pull request to the merge queue May 26, 2026
@gz gz removed this pull request from the merge queue due to a manual request May 26, 2026
@mihaibudiu mihaibudiu added this pull request to the merge queue May 26, 2026
@gz gz removed this pull request from the merge queue due to a manual request May 26, 2026
@mihaibudiu mihaibudiu added this pull request to the merge queue May 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch May 26, 2026
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
@mihaibudiu mihaibudiu enabled auto-merge May 26, 2026 23:40
@mihaibudiu mihaibudiu added this pull request to the merge queue May 26, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 27, 2026
@mihaibudiu mihaibudiu added this pull request to the merge queue May 27, 2026
Merged via the queue into feldera:main with commit 03c68f8 May 27, 2026
1 check passed
@mihaibudiu mihaibudiu deleted the sort-bool branch May 27, 2026 12:36
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.

3 participants