Skip to content

Commit

Permalink
Added mapd to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed May 2, 2018
1 parent 71c9366 commit 465fafd
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 10 deletions.
8 changes: 0 additions & 8 deletions ci/datamgr.py
Expand Up @@ -226,14 +226,6 @@ def mapd(schema, tables, data_directory, **params):
port=params['port'], dbname=params['database']
)

# drop tables if exist
for table in tables:
try:
conn.execute('DROP TABLE {}'.format(table))
except Exception as e:
click.echo('[MAPD|WW] {}'.format(str(e)))
click.echo('[MAPD|II] Dropping tables ... OK')

# create tables
for stmt in schema.read().split(';'):
stmt = stmt.strip()
Expand Down
55 changes: 54 additions & 1 deletion ibis/mapd/operations.py
Expand Up @@ -322,6 +322,12 @@ def literal(translator, expr):
raise NotImplementedError(type(expr))


def raise_unsupported_op_error(translator, expr, *args):
msg = "MapD backend doesn't support {} operation!"
op = expr.op()
raise com.UnsupportedOperationError(msg.format(type(op)))


class CaseFormatter(object):

def __init__(self, translator, base, cases, results, default):
Expand Down Expand Up @@ -535,7 +541,6 @@ class ByteLength(ops.StringLength):

# DATE
_date_ops = {
ops.Date: unary('toDate'),
ops.DateTruncate: _timestamp_truncate,
ops.TimestampTruncate: _timestamp_truncate,

Expand Down Expand Up @@ -571,6 +576,53 @@ class ByteLength(ops.StringLength):
ops.TableColumn: _table_column,
}

# UNSUPPORTED OPERATIONS
_unsupported_ops = [
# generic/aggregation
ops.WindowOp,
ops.DecimalPrecision,
ops.DecimalScale,
ops.BaseConvert,
ops.CumulativeSum,
ops.CumulativeMin,
ops.CumulativeMax,
ops.CumulativeMean,
ops.CumulativeAny,
ops.CumulativeAll,
ops.IdenticalTo,
ops.HLLCardinality,
ops.Arbitrary,
ops.RowNumber,
ops.DenseRank,
ops.MinRank,
ops.PercentRank,
ops.FirstValue,
ops.LastValue,
ops.NthValue,
ops.Lag,
ops.Lead,
ops.NTile,
# string
ops.Lowercase,
ops.Uppercase,
ops.StringFind,
ops.FindInSet,
ops.StringReplace,
ops.StringJoin,
ops.StringSplit,
ops.Repeat,
ops.RegexExtract,
ops.RegexReplace,
ops.ParseURL,
# date/time/timestamp
ops.TimestampFromUNIX,
ops.Date,
ops.TimeTruncate
]

_unsupported_ops = {k: raise_unsupported_op_error for k in _unsupported_ops}

# registry
_operation_registry = impala_compiler._operation_registry.copy()

_operation_registry.update(_general_ops)
Expand All @@ -584,3 +636,4 @@ class ByteLength(ops.StringLength):
_operation_registry.update(_string_ops)
_operation_registry.update(_date_ops)
_operation_registry.update(_agg_ops)
_operation_registry.update(_unsupported_ops)
3 changes: 2 additions & 1 deletion ibis/tests/all/conftest.py
Expand Up @@ -3,7 +3,7 @@

from ibis.compat import Path
from ibis.tests.backends import (Csv, Parquet, Pandas,
SQLite, Postgres, MySQL,
SQLite, Postgres, MySQL, MapD,
Clickhouse, Impala, BigQuery)


Expand All @@ -30,6 +30,7 @@ def data_directory():
pytest.param(Pandas, marks=pytest.mark.pandas),
pytest.param(SQLite, marks=pytest.mark.sqlite),
pytest.param(Postgres, marks=pytest.mark.postgres),
pytest.param(MapD, marks=pytest.mark.mapd),
pytest.param(MySQL, marks=pytest.mark.mysql),
pytest.param(Clickhouse, marks=pytest.mark.clickhouse),
pytest.param(BigQuery, marks=pytest.mark.bigquery),
Expand Down
19 changes: 19 additions & 0 deletions ibis/tests/backends.py
Expand Up @@ -181,6 +181,25 @@ def connect(self, data_directory):
database=database)


class MapD(Backend):
check_dtype = False
check_names = False
supports_window_operations = False
additional_skipped_operations = frozenset()
supports_divide_by_zero = False
returned_timestamp_unit = 's'

def connect(self, data_directory):
user = os.environ.get('IBIS_TEST_MAPD_USER', 'mapd')
password = os.environ.get(
'IBIS_TEST_MAPD_PASSWORD', 'HyperInteractive')
host = os.environ.get('IBIS_TEST_MAPD_HOST', 'localhost')
database = os.environ.get('IBIS_TEST_MAPD_DATABASE', 'ibis_testing')
return ibis.mapd.connect(
host=host, user=user, password=password, database=database
)


class MySQL(Backend):
check_dtype = False
supports_window_operations = False
Expand Down

0 comments on commit 465fafd

Please sign in to comment.