Skip to content

Commit

Permalink
Define PythonRowRangeClause using NamedTuple
Browse files Browse the repository at this point in the history
This is equivalent but this has the benefit of allowing
efining defaults value in Python 3.6, which aren't
available via the `namedtuple` factory
(only have been added in Python 3.7).

See: https://docs.python.org/3/library/typing.html#typing.NamedTuple
See: https://docs.python.org/3/library/collections.html#collections.namedtuple

Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan committed Sep 15, 2023
1 parent ccea10a commit 639b4a5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions python/arcticdb/version_store/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
import pandas as pd

from typing import Dict
from typing import Dict, NamedTuple

from arcticdb.exceptions import ArcticNativeException, UserInputException
from arcticdb.version_store._normalization import normalize_dt_range_to_ts
Expand Down Expand Up @@ -266,12 +266,16 @@ def value_list_from_args(*args):
PythonProjectionClause = namedtuple("PythonProjectionClause", ["name", "expr"])
PythonGroupByClause = namedtuple("PythonGroupByClause", ["name"])
PythonAggregationClause = namedtuple("PythonAggregationClause", ["aggregations"])
PythonRowRangeClause = namedtuple(
"PythonRowRangeClause", ["row_range_type", "n", "start", "end"], defaults=(None, None, None, None)
)
PythonDateRangeClause = namedtuple("PythonDateRangeClause", ["start", "end"])


class PythonRowRangeClause(NamedTuple):
row_range_type: _RowRangeType
n: int = None
start: int = None
end: int = None


class QueryBuilder:
"""
Build a query to process read results with. Syntax is designed to be similar to Pandas:
Expand Down

0 comments on commit 639b4a5

Please sign in to comment.