Skip to content

Commit

Permalink
FEAT: [mapd] Added float32 and geospatial types for create table from…
Browse files Browse the repository at this point in the history
… schema

resolves #1753
Author: Ivan Ogasawara <ivan.ogasawara@gmail.com>

Closes #1755 from xmnlab/add-float32-sql-type-names and squashes the following commits:

cea890e [Ivan Ogasawara] Applied suggestion from review
28bf106 [Ivan Ogasawara] Applied suggestion from review
435b525 [Ivan Ogasawara] Applied changes from review.
5316f93 [Ivan Ogasawara] [mapd] Added float32 and geospatial types for create table from schema
  • Loading branch information
xmnlab authored and cpcloud committed Apr 5, 2019
1 parent 65bdb04 commit 80db366
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
5 changes: 0 additions & 5 deletions ibis/mapd/ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,3 @@ def pieces(self):

def compile(self):
return '\n'.join(self.pieces)


def _mapd_input_signature(inputs):
# TODO: varargs '{}...'.format(val)
return ', '.join(map(_type_to_sql_string, inputs))
18 changes: 11 additions & 7 deletions ibis/mapd/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,23 @@
import ibis.expr.operations as ops

_sql_type_names = {
'boolean': 'boolean',
'date': 'date',
'decimal': 'decimal',
'double': 'double',
'float32': 'float',
'float64': 'double',
'int8': 'smallint',
'int16': 'smallint',
'int32': 'int',
'int64': 'bigint',
'float': 'float',
'float64': 'double',
'double': 'double',
'linestring': 'linestring',
'multipolygon': 'multipolygon',
'point': 'point',
'polygon': 'polygon',
'string': 'text',
'boolean': 'boolean',
'timestamp': 'timestamp',
'decimal': 'decimal',
'date': 'date',
'time': 'time',
'timestamp': 'timestamp',
}


Expand Down
33 changes: 33 additions & 0 deletions ibis/mapd/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,36 @@ def test_union_op(alltypes):
expr = t1.union(t2)
with pytest.raises(com.UnsupportedOperationError):
expr.compile()


def test_create_table_schema(con):
t_name = 'mytable'

con.drop_table(t_name, force=True)

schema = ibis.schema([
('a', 'float'),
('b', 'double'),
('c', 'int32'),
('d', 'int64'),
('x', 'point'),
('y', 'linestring'),
('z', 'polygon'),
('w', 'multipolygon')
])

con.create_table(t_name, schema=schema)

try:
t = con.table(t_name)

assert isinstance(t.a, ir.FloatingColumn)
assert isinstance(t.b, ir.FloatingColumn)
assert isinstance(t.c, ir.IntegerColumn)
assert isinstance(t.d, ir.IntegerColumn)
assert isinstance(t.x, ir.PointColumn)
assert isinstance(t.y, ir.LineStringColumn)
assert isinstance(t.z, ir.PolygonColumn)
assert isinstance(t.w, ir.MultiPolygonColumn)
finally:
con.drop_table(t_name)

0 comments on commit 80db366

Please sign in to comment.