Skip to content

refactor(datatypes): fully remove unused DataType.name #11102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ibis/backends/sql/compilers/impala.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def visit_NonNullLiteral(self, op, *, value, dtype):
)
elif dtype.is_array() or dtype.is_map() or dtype.is_struct():
raise com.UnsupportedBackendType(
f"Impala does not support {dtype.name.lower()} literals"
f"Impala does not support {dtype.__class__.__name__.lower()} literals"
)
elif dtype.is_uuid():
return sge.convert(str(value))
Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/sql/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def to_ibis(cls, typ: sge.DataType, nullable: bool | None = None) -> dt.DataType
def from_ibis(cls, dtype: dt.DataType) -> sge.DataType:
"""Convert an Ibis dtype to an sqlglot dtype."""

if method := getattr(cls, f"_from_ibis_{dtype.name}", None):
if method := getattr(cls, f"_from_ibis_{dtype.__class__.__name__}", None):
return method(dtype)
else:
return sge.DataType(this=_to_sqlglot_types[type(dtype)])
Expand Down
12 changes: 4 additions & 8 deletions ibis/expr/datatypes/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,6 @@ def column(self): ...
def _pretty_piece(self) -> str:
return ""

# TODO(kszucs): should remove it, only used internally
@property
def name(self) -> str:
"""Return the name of the data type."""
return self.__class__.__name__

@classmethod
def __coerce__(cls, value, **kwargs):
if isinstance(value, cls):
Expand All @@ -209,7 +203,8 @@ def __call__(self, **kwargs):

def __str__(self) -> str:
prefix = "!" * (not self.nullable)
return f"{prefix}{self.name.lower()}{self._pretty_piece}"
name = self.__class__.__name__.lower()
return f"{prefix}{name}{self._pretty_piece}"

def equals(self, other: DataType) -> bool:
if not isinstance(other, DataType):
Expand Down Expand Up @@ -962,7 +957,8 @@ def __getitem__(self, key: str) -> DataType:
return self.fields[key]

def __repr__(self) -> str:
return f"'{self.name}({list(self.items())}, nullable={self.nullable})"
name = self.__class__.__name__
return f"'{name}({list(self.items())}, nullable={self.nullable})"

@property
def _pretty_piece(self) -> str:
Expand Down
Loading