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

Schema output doesn't show if the field is non-nullable #2115

Closed
xmnlab opened this issue Mar 5, 2020 · 1 comment · Fixed by #2117
Closed

Schema output doesn't show if the field is non-nullable #2115

xmnlab opened this issue Mar 5, 2020 · 1 comment · Fixed by #2117
Labels
feature Features or general enhancements ux User experience related issues

Comments

@xmnlab
Copy link
Contributor

xmnlab commented Mar 5, 2020

The current schema doesn't show if the field is non-nullable

>>> ibis.schema([
...     ('foo', 'int64'),
...     ('bar', ibis.expr.datatypes.int64(nullable=False)),
...     ('baz', 'boolean*')
... ])

ibis.Schema {  
  foo  int64
  bar  int64
  baz  boolean
}

Desired behavior:

The output should show if the type is non-nullable, eg:

ibis.Schema {  
  foo  int64
  bar  int64[non-nullable]
  baz  boolean
}
@xmnlab
Copy link
Contributor Author

xmnlab commented Mar 5, 2020

suggestion: change DataType.__str__ method:

diff --git a/ibis/expr/datatypes.py b/ibis/expr/datatypes.py
index 9f469fb9..ec9998c9 100644
--- a/ibis/expr/datatypes.py
+++ b/ibis/expr/datatypes.py
@@ -83,7 +83,10 @@ class DataType:
         )
 
     def __str__(self) -> str:
-        return self.name.lower()
+        return '{}{}'.format(
+            self.name.lower(),
+            '[non-nullable]' if not self.nullable else ''
+        )
 
     @property
     def name(self) -> str:

@jreback jreback added feature Features or general enhancements ux User experience related issues labels Mar 12, 2020
@jreback jreback added this to the Future milestone Mar 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features or general enhancements ux User experience related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants