fix: inefficient select with large row number (#15730)

Fixes #15716

# Description

Returns None early if the input iterator is depleted.

# User-Facing Changes

Should be none

# Tests + Formatting

+1

# After Submitting
This commit is contained in:
zc he 2025-05-10 16:28:18 +08:00 committed by GitHub
parent a9252c5075
commit 8352a09117
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -310,7 +310,7 @@ impl Iterator for NthIterator {
return self.input.next();
} else {
self.current += 1;
let _ = self.input.next();
let _ = self.input.next()?;
continue;
}
} else {

View File

@ -134,6 +134,12 @@ fn selects_a_row() {
});
}
#[test]
fn selects_large_row_number() {
let actual = nu!("seq 1 5 | select 9999999999 | to nuon");
assert_eq!(actual.out, "[]");
}
#[test]
fn selects_many_rows() {
Playground::setup("select_test_2", |dirs, sandbox| {