Skip to content

Commit

Permalink
refactor(datatypes): remove Enum
Browse files Browse the repository at this point in the history
Enum types are now aliased to String. There was no functionality
provided by Enums, and in every backend that we implement that supports
them they are restricted to Strings.

BREAKING CHANGE: Enums are now strings. Likely no action needed since no functionality existed.
  • Loading branch information
cpcloud authored and kszucs committed Nov 21, 2022
1 parent 23c552f commit 145e706
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 29 deletions.
14 changes: 3 additions & 11 deletions ibis/expr/datatypes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,17 +752,6 @@ def _pretty_piece(self) -> str:
return f"<{self.value_type}>"


@public
class Enum(DataType):
"""Enumeration values."""

rep_type = datatype
value_type = datatype

scalar = ir.EnumScalar
column = ir.EnumColumn


@public
class Map(Variadic):
"""Associative array values."""
Expand Down Expand Up @@ -959,6 +948,8 @@ class INET(String):
inet = INET()
decimal = Decimal()

Enum = String

public(
null=null,
boolean=boolean,
Expand Down Expand Up @@ -995,4 +986,5 @@ class INET(String):
macaddr=macaddr,
inet=inet,
decimal=decimal,
Enum=Enum,
)
4 changes: 2 additions & 2 deletions ibis/expr/datatypes/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def infer_integer(value: int, prefer_unsigned: bool = False) -> dt.Integer:


@infer.register(enum.Enum)
def infer_enum(value: enum.Enum) -> dt.Enum:
return dt.Enum(infer(value.name), infer(value.value))
def infer_enum(_: enum.Enum) -> dt.String:
return dt.string


@infer.register(bool)
Expand Down
15 changes: 0 additions & 15 deletions ibis/expr/types/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@
from ibis.expr.types.generic import Column, Scalar, Value


@public
class EnumValue(Value):
pass # noqa: E701,E302


@public
class EnumScalar(Scalar, EnumValue):
pass # noqa: E701,E302


@public
class EnumColumn(Column, EnumValue):
pass # noqa: E701,E302


@public
class SetValue(Value):
pass # noqa: E701,E302
Expand Down
2 changes: 1 addition & 1 deletion ibis/tests/expr/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ class Foo(enum.Enum):
]
),
),
(Foo.a, dt.Enum(dt.string, dt.int8)),
(Foo.a, dt.Enum()),
],
)
def test_infer_dtype(value, expected_dtype):
Expand Down

0 comments on commit 145e706

Please sign in to comment.