Skip to content

Commit

Permalink
refactor(ir): remove UnnamedMarker
Browse files Browse the repository at this point in the history
  • Loading branch information
kszucs authored and cpcloud committed Jan 11, 2023
1 parent 6f87064 commit dd352b1
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ibis/backends/base/sql/alchemy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _exists_subquery(t, op):
filtered = (
op.foreign_table.to_expr()
.filter([pred.to_expr() for pred in op.predicates])
.projection([ir.literal(1).name(ir.core.unnamed)])
.projection([ir.literal(1).name("")])
)

sub_ctx = ctx.subcontext()
Expand Down
3 changes: 1 addition & 2 deletions ibis/backends/base/sql/compiler/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import ibis.common.exceptions as com
import ibis.expr.operations as ops
from ibis.backends.base.sql.registry import operation_registry, quote_identifier
from ibis.expr.types.core import unnamed


class QueryContext:
Expand Down Expand Up @@ -199,7 +198,7 @@ def _needs_name(self, op):
# This column has been given an explicitly different name
return False

return op.name is not unnamed
return bool(op.name)

def name(self, translated, name, force=True):
return f'{translated} AS {quote_identifier(name, force=force)}'
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/base/sql/registry/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def table_column(translator, op):
def exists_subquery(translator, op):
ctx = translator.context

dummy = ir.literal(1).name(ir.core.unnamed)
dummy = ir.literal(1).name("")

filtered = op.foreign_table.to_expr().filter(
[pred.to_expr() for pred in op.predicates]
Expand Down
4 changes: 2 additions & 2 deletions ibis/expr/operations/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import ibis.expr.rules as rlz
from ibis.common.graph import Node as Traversable
from ibis.common.grounds import Concrete
from ibis.util import UnnamedMarker, deprecated
from ibis.util import deprecated

if TYPE_CHECKING:
import ibis.expr.datatypes as dt
Expand Down Expand Up @@ -92,7 +92,7 @@ def to_expr(self):
@public
class Alias(Value):
arg = rlz.any
name = rlz.instance_of((str, UnnamedMarker))
name = rlz.instance_of(str)

output_shape = rlz.shape_like("arg")
output_dtype = rlz.dtype_like("arg")
Expand Down
4 changes: 2 additions & 2 deletions ibis/expr/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from ibis.common.exceptions import IntegrityError
from ibis.common.grounds import Concrete
from ibis.common.validators import instance_of, tuple_of, validator
from ibis.util import UnnamedMarker, indent
from ibis.util import indent

if TYPE_CHECKING:
import pandas as pd
Expand Down Expand Up @@ -46,7 +46,7 @@ def datatype(arg, **kwargs):
class Schema(Concrete):
"""An object for holding table schema information."""

names = tuple_of(instance_of((str, UnnamedMarker)))
names = tuple_of(instance_of(str))
"""A sequence of [`str`][str] indicating the name of each column."""
types = tuple_of(datatype)
"""A sequence of [DataType][ibis.expr.datatypes.DataType] objects
Expand Down
5 changes: 1 addition & 4 deletions ibis/expr/types/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ibis.common.exceptions import IbisError, IbisTypeError, TranslationError
from ibis.common.grounds import Immutable
from ibis.config import _default_backend, options
from ibis.util import UnnamedMarker, experimental
from ibis.util import experimental

if TYPE_CHECKING:
import pyarrow as pa
Expand Down Expand Up @@ -381,9 +381,6 @@ def as_table(self) -> ir.Table:
raise NotImplementedError(type(self))


unnamed = UnnamedMarker()


def _binop(
op_class: type[ops.Binary], left: ir.Value, right: ir.Value
) -> ir.Value | NotImplemented:
Expand Down
4 changes: 0 additions & 4 deletions ibis/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ def __repr__(self):
return f"{self.__class__.__name__}({super().__repr__()})"


class UnnamedMarker:
pass


def guid() -> str:
"""Return a uuid4 hexadecimal value."""
return uuid4().hex
Expand Down

0 comments on commit dd352b1

Please sign in to comment.