Skip to content
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

[FEAT] expose more type info #2762

Merged
Merged
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
3 changes: 3 additions & 0 deletions daft/daft.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,13 @@ class PyDataType:
def is_numeric(self) -> builtins.bool: ...
def is_image(self) -> builtins.bool: ...
def is_fixed_shape_image(self) -> builtins.bool: ...
def is_list(self) -> builtins.bool: ...
def is_tensor(self) -> builtins.bool: ...
def is_fixed_shape_tensor(self) -> builtins.bool: ...
def is_map(self) -> builtins.bool: ...
def is_logical(self) -> builtins.bool: ...
def is_boolean(self) -> builtins.bool: ...
def is_string(self) -> builtins.bool: ...
def is_temporal(self) -> builtins.bool: ...
def is_equal(self, other: Any) -> builtins.bool: ...
@staticmethod
Expand Down
9 changes: 9 additions & 0 deletions daft/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,15 @@ def _is_fixed_shape_image_type(self) -> builtins.bool:
def _is_numeric_type(self) -> builtins.bool:
return self._dtype.is_numeric()

def _is_list(self) -> builtins.bool:
return self._dtype.is_list()

def _is_boolean(self) -> builtins.bool:
return self._dtype.is_boolean()

def _is_string(self) -> builtins.bool:
return self._dtype.is_string()

def _is_map(self) -> builtins.bool:
return self._dtype.is_map()

Expand Down
15 changes: 15 additions & 0 deletions src/daft-core/src/datatypes/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,21 @@ impl DataType {
matches!(self, DataType::Map(..))
}

#[inline]
pub fn is_list(&self) -> bool {
matches!(self, DataType::List(..))
}

#[inline]
pub fn is_string(&self) -> bool {
matches!(self, DataType::Utf8)
}

#[inline]
pub fn is_boolean(&self) -> bool {
matches!(self, DataType::Boolean)
}

#[inline]
pub fn is_null(&self) -> bool {
match self {
Expand Down
12 changes: 12 additions & 0 deletions src/daft-core/src/python/datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,18 @@ impl PyDataType {
Ok(self.dtype.is_map())
}

pub fn is_list(&self) -> PyResult<bool> {
Ok(self.dtype.is_list())
}

pub fn is_boolean(&self) -> PyResult<bool> {
Ok(self.dtype.is_boolean())
}

pub fn is_string(&self) -> PyResult<bool> {
Ok(self.dtype.is_string())
}

pub fn is_logical(&self) -> PyResult<bool> {
Ok(self.dtype.is_logical())
}
Expand Down
Loading