vastorbit.sql.functions.overlaps¶
- vastorbit.sql.functions.overlaps(start0: Annotated[str | list[str] | StringSQL | list[StringSQL], ''], end0: Annotated[str | list[str] | StringSQL | list[StringSQL], ''], start1: Annotated[str | list[str] | StringSQL | list[StringSQL], ''], end1: Annotated[str | list[str] | StringSQL | list[StringSQL], '']) StringSQL¶
Evaluates two time periods and returns true when they overlap, false otherwise.
- Parameters:
start0 (SQLExpression) – DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the beginning of a time period.
end0 (SQLExpression) – DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the end of a time period.
start1 (SQLExpression) – DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the beginning of a time period.
end1 (SQLExpression) – DATE, TIME, or TIMESTAMP/TIMESTAMPTZ value that specifies the end of a time period.
- Returns:
SQL string.
- Return type:
StringSQL
Examples
First, let’s import the VastFrame in order to create a dummy dataset.
from vastorbit import VastFrame
Now, let’s import the vastorbit SQL functions.
import vastorbit.sql.functions as vof
We can now build a dummy dataset.
df = VastFrame( { "start0": ['1993-11-03'], "end0": ['1993-03-12'], "start1": ['1993-11-30'], "end1": ['1994-11-30'], }, ) df["start0"].astype("timestamp") df["start1"].astype("timestamp") df["end0"].astype("timestamp") df["end1"].astype("timestamp")
Now, let’s go ahead and apply the function.
df["overlaps"] = vof.overlaps(df["start0"], df["end0"], df["start1"], df["end1"]) display(df)
📅start0Timestamp📅end0Timestamp📅start1Timestamp📅end1Timestamp0|1overlapsBoolean1 1993-11-03 00:00:00 1993-12-03 00:00:00 1993-11-30 00:00:00 1994-11-30 00:00:00 ✓ Note
It’s crucial to utilize vastorbit SQL functions in coding, as they can be updated over time with new syntax. While SQL functions typically remain stable, they may vary across platforms or versions. vastorbit effectively manages these changes, a task not achievable with pure SQL.
See also
VastFrame.eval(): Evaluates the expression.