Skip to content

Commit

Permalink
fix(api): forbid using asc/desc in selections
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist authored and kszucs committed Feb 12, 2024
1 parent 7d44d77 commit 62992c3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ibis/expr/operations/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
from ibis.common.patterns import Between, InstanceOf
from ibis.common.typing import Coercible, VarTuple
from ibis.expr.operations.core import Alias, Column, Node, Scalar, Value
from ibis.expr.operations.sortkeys import SortKey # noqa: TCH001
from ibis.expr.operations.sortkeys import SortKey
from ibis.expr.schema import Schema
from ibis.formats import TableProxy # noqa: TCH001

T = TypeVar("T")

Unaliased = Annotated[T, ~InstanceOf(Alias)]
NonSortKey = Annotated[T, ~InstanceOf(SortKey)]


@public
Expand Down Expand Up @@ -171,7 +172,7 @@ def _check_integrity(values, allowed_parents):
@public
class Project(Relation):
parent: Relation
values: FrozenDict[str, Unaliased[Value]]
values: FrozenDict[str, NonSortKey[Unaliased[Value]]]

def __init__(self, parent, values):
_check_integrity(values.values(), {parent})
Expand Down
9 changes: 9 additions & 0 deletions ibis/tests/expr/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ def test_projection_duplicate_names(table):
table.select([table.c, table.c])


def test_projection_sort_keys_errors(table):
"""Forbid using `asc`/`desc` in selections"""
with pytest.raises(ValidationError):
table.select([table.c.desc()])

with pytest.raises(ValidationError):
table.mutate(new=table.c.asc())


def test_projection_invalid_root(table):
schema1 = {"foo": "double", "bar": "int32"}

Expand Down

0 comments on commit 62992c3

Please sign in to comment.