-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: Use a dataclass for execution options (#600)
This reduces some duplication, in that we don't need to have the FFI define a Python-compatible copy of the Rust execution options. Instead we have it read straight from the documented dataclass.
- Loading branch information
1 parent
3266ee4
commit 39b07f9
Showing
8 changed files
with
76 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from dataclasses import dataclass | ||
from typing import Optional | ||
|
||
|
||
@dataclass | ||
class ExecutionOptions: | ||
"""Execution options for a query. | ||
Attributes | ||
---------- | ||
row_limit : Optional[int] | ||
The maximum number of rows to return. | ||
If not specified (the default), all rows are returned. | ||
""" | ||
|
||
row_limit: Optional[int] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,45 @@ | ||
import sparrow_py | ||
from dataclasses import dataclass | ||
|
||
from ._expr import Expr | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Window(object): | ||
"""Base class for window functions.""" | ||
|
||
def __init__(self) -> None: | ||
pass | ||
|
||
|
||
@dataclass(frozen=True) | ||
class SinceWindow(Window): | ||
"""Window since the last time a predicate was true.""" | ||
""" | ||
Window since the last time a predicate was true. | ||
Aggregations will contain all values starting from the last time the predicate | ||
evaluated to true (inclusive). | ||
def __init__(self, predicate: "sparrow_py.Expr") -> None: | ||
super().__init__() | ||
self._predicate = predicate | ||
Parameters | ||
---------- | ||
predicate : Expr | ||
The predicate to use for the window. | ||
Each time the predicate evaluates to true the window will be cleared. | ||
""" | ||
|
||
predicate: Expr | ||
|
||
|
||
@dataclass(frozen=True) | ||
class SlidingWindow(Window): | ||
"""Sliding windows where the width is a multiple of some condition.""" | ||
""" | ||
Window for the last `duration` intervals of some `predicate`. | ||
Parameters | ||
---------- | ||
duration : int | ||
The number of sliding intervals to use in the window. | ||
predicate : Expr | ||
The predicate to use for the window. | ||
Each time the predicate evaluates to true the window starts a new interval. | ||
""" | ||
|
||
def __init__(self, duration: int, predicate: "sparrow_py.Expr") -> None: | ||
super().__init__() | ||
self._duration = duration | ||
self._predicate = predicate | ||
duration: int | ||
predicate: Expr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters