Skip to content

Commit

Permalink
Add some light type testing for json, jsonb, uuid.
Browse files Browse the repository at this point in the history
  • Loading branch information
ian-r-rose committed Sep 26, 2019
1 parent b514069 commit 3748ef9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ibis/sql/tests/test_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,32 @@ def test_sqla_schema_conversion(self):

assert_equal(schema, expected)

def test_sqla_postgres_schema_conversion(self):
typespec = [
# name, type, nullable
('json', sa.dialects.postgresql.JSON, True, dt.any),
('jsonb', sa.dialects.postgresql.JSONB, True, dt.any),
('uuid', sa.dialects.postgresql.UUID, True, dt.any),
]

sqla_types = []
ibis_types = []
for name, t, nullable, ibis_type in typespec:
sqla_type = sa.Column(name, t, nullable=nullable)
sqla_types.append(sqla_type)
ibis_types.append((name, ibis_type(nullable=nullable)))

# Create a table with placeholder stubs for JSON, JSONB, and UUID.
engine = sa.create_engine('postgresql://')
table = sa.Table('tname', sa.MetaData(bind=engine), *sqla_types)

# Check that we can correctly create a schema with dt.any for the
# missing types.
schema = alch.schema_from_table(table)
expected = ibis.schema(ibis_types)

assert_equal(schema, expected)

@pytest.mark.xfail(raises=AssertionError, reason='NYT')
def test_ibis_to_sqla_conversion(self):
assert False
Expand Down

0 comments on commit 3748ef9

Please sign in to comment.