Skip to content

Commit

Permalink
refactor(api): remove the remnants of now unsupported timecontext f…
Browse files Browse the repository at this point in the history
…eature (#8721)

The timecontext feature was only supported by the pandas, dask and
pyspark backends.
Since the epic split refactor none of the ported backends support this
feature.

BREAKING CHANGE: timecontext feature is removed
  • Loading branch information
kszucs authored Mar 21, 2024
1 parent 32b7514 commit 0a00a05
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 201 deletions.
2 changes: 0 additions & 2 deletions docs/_quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ website:

- section: Configuration
contents:
- reference/ContextAdjustment.qmd
- reference/Interactive.qmd
- reference/Options.qmd
- reference/Repr.qmd
Expand Down Expand Up @@ -623,7 +622,6 @@ quartodoc:
desc: "Ibis configuration"
package: ibis.config
contents:
- ContextAdjustment
- Interactive
- Options
- Repr
Expand Down
2 changes: 0 additions & 2 deletions ibis/backends/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,6 @@ def execute(self, expr, params=None, limit="default", **kwargs):
"""
self._run_pre_execute_hooks(expr)

# TODO: upstream needs to pass params to raw_sql, I think.
kwargs.pop("timecontext", None)
sql = self.compile(expr, limit=limit, params=params, **kwargs)
self._log(sql)
cursor = self.raw_sql(sql, params=params, **kwargs)
Expand Down
12 changes: 3 additions & 9 deletions ibis/backends/dask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ def disconnect(self) -> None:
def version(self):
return dask.__version__

def _validate_args(self, expr, limit, timecontext):
if timecontext is not None:
raise com.UnsupportedArgumentError(
"The Dask backend does not support timecontext"
)
def _validate_args(self, expr, limit):
if limit != "default" and limit is not None:
raise com.UnsupportedArgumentError(
"limit parameter to execute is not yet implemented in the "
Expand All @@ -88,12 +84,11 @@ def compile(
expr: ir.Expr,
params: dict | None = None,
limit: int | None = None,
timecontext=None,
**kwargs,
):
from ibis.backends.dask.executor import DaskExecutor

self._validate_args(expr, limit, timecontext)
self._validate_args(expr, limit)
params = params or {}
params = {k.op() if isinstance(k, ir.Expr) else k: v for k, v in params.items()}

Expand All @@ -104,12 +99,11 @@ def execute(
expr: ir.Expr,
params: Mapping[ir.Expr, object] | None = None,
limit: str = "default",
timecontext=None,
**kwargs,
):
from ibis.backends.dask.executor import DaskExecutor

self._validate_args(expr, limit, timecontext)
self._validate_args(expr, limit)
params = params or {}
params = {k.op() if isinstance(k, ir.Expr) else k: v for k, v in params.items()}

Expand Down
149 changes: 0 additions & 149 deletions ibis/backends/tests/test_timecontext.py

This file was deleted.

17 changes: 0 additions & 17 deletions ibis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ def __call__(self, options):
return self._with_temporary(options)


class ContextAdjustment(Config):
"""Options related to time context adjustment.
Attributes
----------
time_col : str
Name of the timestamp column for execution with a `timecontext`. See
`ibis/expr/timecontext.py` for details.
"""

time_col: str = "time"


class SQL(Config):
"""SQL-related options.
Expand Down Expand Up @@ -153,8 +139,6 @@ class Options(Config):
default_backend : Optional[ibis.backends.BaseBackend]
The default backend to use for execution, defaults to DuckDB if not
set.
context_adjustment : ContextAdjustment
Options related to time context adjustment.
sql: SQL
SQL-related options.
clickhouse : Config | None
Expand All @@ -176,7 +160,6 @@ class Options(Config):
verbose_log: Optional[Callable] = None
graphviz_repr: bool = False
default_backend: Optional[Any] = None
context_adjustment: ContextAdjustment = ContextAdjustment()
sql: SQL = SQL()
clickhouse: Optional[Config] = None
dask: Optional[Config] = None
Expand Down
24 changes: 2 additions & 22 deletions ibis/expr/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
from ibis.backends import BaseBackend
from ibis.expr.visualize import EdgeAttributeGetter, NodeAttributeGetter

TimeContext = tuple[pd.Timestamp, pd.Timestamp]


class _FixedTextJupyterMixin(JupyterMixin):
"""JupyterMixin adds a spurious newline to text, this fixes the issue."""
Expand Down Expand Up @@ -343,7 +341,6 @@ def _find_backend(self, *, use_default: bool = False) -> BaseBackend:
def execute(
self,
limit: int | str | None = "default",
timecontext: TimeContext | None = None,
params: Mapping[ir.Value, Any] | None = None,
**kwargs: Any,
):
Expand All @@ -354,27 +351,18 @@ def execute(
limit
An integer to effect a specific row limit. A value of `None` means
"no limit". The default is in `ibis/config.py`.
timecontext
Defines a time range of `(begin, end)`. When defined, the execution
will only compute result for data inside the time range. The time
range is inclusive of both endpoints. This is conceptually same as
a time filter.
The time column must be named `'time'` and should preserve
across the expression. For example, if that column is dropped then
execute will result in an error.
params
Mapping of scalar parameter expressions to value
kwargs
Keyword arguments
"""
return self._find_backend(use_default=True).execute(
self, limit=limit, timecontext=timecontext, params=params, **kwargs
self, limit=limit, params=params, **kwargs
)

def compile(
self,
limit: int | None = None,
timecontext: TimeContext | None = None,
params: Mapping[ir.Value, Any] | None = None,
pretty: bool = False,
):
Expand All @@ -385,21 +373,13 @@ def compile(
limit
An integer to effect a specific row limit. A value of `None` means
"no limit". The default is in `ibis/config.py`.
timecontext
Defines a time range of `(begin, end)`. When defined, the execution
will only compute result for data inside the time range. The time
range is inclusive of both endpoints. This is conceptually same as
a time filter.
The time column must be named `'time'` and should preserve
across the expression. For example, if that column is dropped then
execute will result in an error.
params
Mapping of scalar parameter expressions to value
pretty
In case of SQL backends, return a pretty formatted SQL query.
"""
return self._find_backend().compile(
self, limit=limit, timecontext=timecontext, params=params, pretty=pretty
self, limit=limit, params=params, pretty=pretty
)

@experimental
Expand Down

0 comments on commit 0a00a05

Please sign in to comment.