Skip to content

Commit

Permalink
Add non-nullable info to schema output. (#2117)
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab authored Mar 17, 2020
1 parent 94cb1ce commit cad629e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Release Notes
* :feature:`2126` Add translation rules for isnull() and notnull() for pyspark backend
* :feature:`2062` Implement read_csv for omniscidb backend
* :feature:`2060` Add initial support for ibis.random function
* :feature:`2117` Add non-nullable info to schema output
* :support:`2096` Added round() support for OmniSciDB
* :feature:`2125` [OmniSciDB] Add support for within, d_fully_within and point
* :support:`2113` Enabled cumulative ops support for OmniSciDB
Expand Down
4 changes: 3 additions & 1 deletion ibis/expr/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def __repr__(self) -> str:
)

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:
Expand Down
17 changes: 17 additions & 0 deletions ibis/expr/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,20 @@ def test_empty_schema():
ibis.Schema {
}"""
assert result == expected


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

sch_str = str(sch)
assert 'foo int64' in sch_str
assert 'foo int64[non-nullable]' not in sch_str
assert 'bar int64[non-nullable]' in sch_str
assert 'baz boolean' in sch_str
assert 'baz boolean[non-nullable]' not in sch_str

0 comments on commit cad629e

Please sign in to comment.