Skip to content

Commit

Permalink
Remove parameters from mapd Fixes #1610
Browse files Browse the repository at this point in the history
Closes #1610

Author: Tony Fast <tony.fast@gmail.com>

Closes #1648 from tonyfast/master and squashes the following commits:

d561787 [Tony Fast] Merge branch 'master' of https://github.com/ibis-project/ibis
a7eb782 [Tony Fast] Trigger build
f9b859f [Tony Fast] Remove fragment_size, page_size, partitions, and shard_count from the  create_table client.
8a27534 [Tony Fast] Add tests to cover the create_table function.
e47d988 [Tony Fast] Add fixtures test_data_db, temp_table, temp_database
a95941d [Tony Fast] Remove parameters from mapd Fixes #1610
  • Loading branch information
tonyfast authored and cpcloud committed Oct 16, 2018
1 parent ac38ada commit 36de943
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 34 deletions.
23 changes: 2 additions & 21 deletions ibis/mapd/client.py
Expand Up @@ -534,8 +534,7 @@ def drop_view(self, name, database=None):
self._execute(statement, False)

def create_table(self, table_name, obj=None, schema=None, database=None,
fragment_size=None, max_rows=None, page_size=None,
partitions=None, shard_count=None):
max_rows=None):
"""
Create a new table in MapD using an Ibis table expression.
Expand All @@ -548,24 +547,10 @@ def create_table(self, table_name, obj=None, schema=None, database=None,
Mutually exclusive with expr, creates an empty table with a
particular schema
database : string, default None (optional)
fragment_size : int, Default None
Number of rows per fragment that is a unit of the table for query
processing. Default = 32 million rows, which is not expected to be
changed.
max_rows : int, Default None
Set the maximum number of rows allowed in a table to create a capped
collection. When this limit is reached, the oldest fragment is
removed. Default = 2^62.
page_size : int, Default None
Number of I/O page bytes. Default = 1MB, which does not need to be
changed.
partitions : string, Default None
Partition strategy option:
SHARDED: Partition table using sharding.
REPLICATED: Partition table using replication.
shard_count : int , Default None
Number of shards to create, typically equal to the number of GPUs
across which the data table is distributed.
Examples
--------
Expand All @@ -592,11 +577,7 @@ def create_table(self, table_name, obj=None, schema=None, database=None,
statement = ddl.CreateTableWithSchema(
table_name, schema,
database=database,
fragment_size=fragment_size,
max_rows=max_rows,
page_size=page_size,
partitions=partitions,
shard_count=shard_count
max_rows=max_rows
)
else:
raise com.IbisError('Must pass expr or schema')
Expand Down
15 changes: 2 additions & 13 deletions ibis/mapd/ddl.py
Expand Up @@ -100,27 +100,16 @@ def compile(self):

class CreateTableWithSchema(CreateTable):
def __init__(
self, table_name, schema, database=None, fragment_size=None,
max_rows=None, page_size=None, partitions=None, shard_count=None
self, table_name, schema, database=None, max_rows=None
):
self.table_name = table_name
self.database = database
self.schema = schema
self.fragment_size = fragment_size
self.max_rows = max_rows
self.page_size = page_size
self.partitions = partitions
self.shard_count = shard_count

@property
def with_params(self):
return dict(
fragment_size=self.fragment_size,
max_rows=self.max_rows,
page_size=self.page_size,
partitions=self.partitions,
shard_count=self.shard_count
)
return dict(max_rows=self.max_rows)

@property
def _pieces(self):
Expand Down
31 changes: 31 additions & 0 deletions ibis/mapd/tests/conftest.py
@@ -1,4 +1,5 @@
import ibis
import ibis.util as util
import os
import pytest

Expand Down Expand Up @@ -50,3 +51,33 @@ def translate():
dialect = MapDDialect()
context = dialect.make_context()
return lambda expr: dialect.translator(expr, context).get_result()


def _random_identifier(suffix):
return '__ibis_test_{}_{}'.format(suffix, util.guid())


@pytest.fixture
def temp_table(con):
name = _random_identifier('table')
try:
yield name
finally:
assert con.exists_table(name), name
con.drop_table(name)


@pytest.fixture(scope='session')
def test_data_db():
return MAPD_DB


@pytest.fixture
def temp_database(con, test_data_db):
name = _random_identifier('database')
con.create_database(name)
try:
yield name
finally:
con.set_database(test_data_db)
con.drop_database(name, force=True)
10 changes: 10 additions & 0 deletions ibis/mapd/tests/test_client.py
Expand Up @@ -60,3 +60,13 @@ def test_compile_toplevel():
result = ibis.mapd.compile(expr)
expected = 'SELECT sum("foo") AS "sum"\nFROM t0' # noqa
assert str(result) == expected


def text_exists_table_with_database(
con, alltypes, test_data_db, temp_table, temp_database
):
tmp_db = test_data_db
con.create_table(temp_table, alltypes, database=tmp_db)

assert con.exists_table(temp_table, database=tmp_db)
assert not con.exists_table(temp_table, database=temp_database)

0 comments on commit 36de943

Please sign in to comment.