Skip to content

Commit

Permalink
Merge pull request #311 from mabel-dev/BUG/#310
Browse files Browse the repository at this point in the history
BUG/#310
  • Loading branch information
joocer authored Jul 23, 2022
2 parents 310b170 + ebbd0e9 commit b0c39fb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ quarter | ✓ | ✓ | ✓ | ✓ |
doy | ✘ | ✓ | ✘ | ✘ | day of year
year | ✓ | ✓ | ✓ | ✓ |

The following convenience extraction functions also exist, however use of `EXTRACT` is recommended.

## Implicit Casting

In many situation where a timestamp is expected, if an ISO1806 formatted string is provided, Opteryx will interpret as a timestamp.
Expand Down
18 changes: 9 additions & 9 deletions docs/SQL Reference/Working with SQL/50 Relation Constructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ Intervals are defined quantifying one or more periods which make up the interval

Recognized interval parts for the `GENERATE_SERIES` function are:

Period | Symbol
------- | -----:
Years | y
Months | mo
Weeks | w
Days | d
Hours | h
Minutes | m
Seconds | s
Period | Symbol | Aliases
------- | :----------------------- | ----
Years | **year** / **years** | y / yr / yrs
Months | **month** / **months** | mo / mon / mons / mth / mths
Weeks | **week** / **weeks** | w / wk / wks
Days | **day** / **days** | d
Hours | **hour** / **hours** | h / hr / hrs
Minutes | **minute** / **minutes** | m / min / mins
Seconds | **second** / **seconds** | s / sec / secs

Where required, periods can be combined to define more complex intervals, for example `1h30m` represents one hour and 30 minutes.

Expand Down
10 changes: 3 additions & 7 deletions opteryx/engine/functions/other_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

from pyarrow import compute

from opteryx.utils import dates


def list_contains(array, item):
"""
Expand Down Expand Up @@ -55,12 +53,10 @@ def search(array, item):
return [None]
if array_type == str:
# return True if the value is in the string
# find_substring returns -1 or an index, we need to convert this to a boolean
# and then to a list of lists for pyarrow
res = compute.find_substring(array, pattern=item, ignore_case=True)
res = ~(res.to_numpy() < 0)
return ([r] for r in res)
return compute.match_substring(array, pattern=item, ignore_case=True)
if array_type == numpy.ndarray:
# converting to a set is faster for a handful of items which is what we're
# almost definitely working with here - note compute.index is about 50x slower
return (
[False] if record is None else [item in set(record)] for record in array
)
Expand Down
2 changes: 1 addition & 1 deletion opteryx/utils/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

TIMEDELTA_REGEX = (
r"((?P<years>\d+)\s?(?:ys?|yrs?|years?))?\s*"
r"((?P<months>\d+)\s?(?:mons?|mths?|months?))?\s*"
r"((?P<months>\d+)\s?(?:mo|mons?|mths?|months?))?\s*"
r"((?P<weeks>\d+)\s?(?:w|wks?|weeks?))?\s*"
r"((?P<days>\d+)\s?(?:d|days?))?\s*"
r"((?P<hours>\d+)\s?(?:h|hrs?|hours?))?\s*"
Expand Down
2 changes: 1 addition & 1 deletion opteryx/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
2) we can import it in setup.py for the same reason
"""

__version__ = "0.2.0-beta.5"
__version__ = "0.2.0-beta.6"
3 changes: 3 additions & 0 deletions tests/sql_battery/test_battery_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@
("SELECT * FROM generate_series('2022-01-01', '2022-12-31', '1 month')", 12, 1),
("SELECT * FROM generate_series('2022-01-01', '2022-12-31', '1 mon')", 12, 1),
("SELECT * FROM generate_series('2022-01-01', '2022-12-31', '1mon')", 12, 1),
("SELECT * FROM generate_series('2022-01-01', '2022-12-31', '1mo')", 12, 1),
("SELECT * FROM generate_series('2022-01-01', '2022-12-31', '1mth')", 12, 1),
("SELECT * FROM generate_series('2022-01-01', '2022-12-31', '1 months')", 12, 1),
("SELECT * FROM generate_series('2022-01-01', '2022-12-31', '1 day')", 365, 1),
("SELECT * FROM generate_series('2020-01-01', '2020-12-31', '1day')", 366, 1),
("SELECT * FROM generate_series('2022-01-01', '2022-12-31', '7 days')", 53, 1),
Expand Down

0 comments on commit b0c39fb

Please sign in to comment.