-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement streaming window functions in cudf-polars #22191
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
Changes from all commits
5861da9
66be8e9
3b15601
6b91f1b
ac73ede
0c8e3de
696bbc9
fdc40c9
e477439
4a6eb6d
0c48e1d
0d6d6b1
01d8777
f1cf13c
4ac5e65
c02eea9
edc704e
5d28fb9
4fc4d25
e1442f2
d632dd4
a7a914a
6bee1b8
4ca3e3c
d690b1e
9dab468
f8db130
3893253
ca1e808
ec93d63
f275788
6051ac5
b272f6c
4d1b482
85f77fd
4c4a33f
563bac7
dad1a79
30e8826
f9fdd46
c6a7b10
3051291
bd076c3
12620c8
5f4dd3e
09a4586
ccaee76
bc584d7
a723dc8
902a4cd
338757a
0a94101
370fc21
5b25eea
7c81adf
68a7983
7975ff4
a6f397c
ea39bd7
658e4bf
d3b6562
7b828be
397d50f
946582a
f7687f1
beee7d9
2b8b357
fc9f7bb
3a23609
6f29e67
564aaf0
4d10e42
8cdf98b
0582e29
191e537
5dbb1dc
232b8ae
dfb3ffe
caadc2f
0db0c7f
f63c7db
80cb585
5480a29
b834838
4cc0003
9491a9e
92501aa
cf5b099
96f24e0
520badf
0483abd
d2a0a60
5b75ae3
590317f
8162194
bb0a75f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Name generation utilities.""" | ||
|
|
@@ -7,11 +7,15 @@ | |
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from cudf_polars.dsl.expr import NamedExpr | ||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import Generator, Iterable | ||
|
|
||
| from cudf_polars.typing import Schema | ||
|
|
||
|
|
||
| __all__ = ["unique_names"] | ||
| __all__ = ["names_to_indices", "unique_names"] | ||
|
|
||
|
|
||
| def unique_names(names: Iterable[str]) -> Generator[str, None, None]: | ||
|
|
@@ -32,3 +36,28 @@ def unique_names(names: Iterable[str]) -> Generator[str, None, None]: | |
| while True: | ||
| yield f"{prefix}{i}" | ||
| i += 1 | ||
|
|
||
|
|
||
| def names_to_indices( | ||
|
rjzamora marked this conversation as resolved.
|
||
| names: tuple[str | NamedExpr, ...], schema: Schema | ||
| ) -> tuple[int, ...]: | ||
| """ | ||
| Return column indices for the given names in schema order. | ||
|
|
||
| Accepts either column names (str) or NamedExpr, so it can be used with | ||
| e.g. ir.left_on, ir.right_on as well as plain name tuples. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| names | ||
| The names to get indices for. | ||
| schema | ||
| The schema to get indices from. | ||
|
|
||
| Returns | ||
| ------- | ||
| The column indices for each name in schema order. | ||
| """ | ||
| keys = list(schema.keys()) | ||
| str_names = [n.name if isinstance(n, NamedExpr) else n for n in names] | ||
| return tuple(keys.index(n) for n in str_names) | ||
|
Comment on lines
+61
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid repeated linear scans and raise a clearer missing-column error. Line 63 does Suggested patch def names_to_indices(
names: tuple[str | NamedExpr, ...], schema: Schema
) -> tuple[int, ...]:
@@
- keys = list(schema.keys())
- str_names = [n.name if isinstance(n, NamedExpr) else n for n in names]
- return tuple(keys.index(n) for n in str_names)
+ index_by_name = {name: i for i, name in enumerate(schema.keys())}
+ str_names = [n.name if isinstance(n, NamedExpr) else n for n in names]
+ try:
+ return tuple(index_by_name[n] for n in str_names)
+ except KeyError as e:
+ missing = e.args[0]
+ raise KeyError(f"Column {missing!r} not found in schema") from NoneAs per coding guidelines "Missing validation causing crashes on invalid input - Add size and type validation before operations." 🤖 Prompt for AI Agents |
||
Uh oh!
There was an error while loading. Please reload this page.