Skip to content

Commit

Permalink
Added mapd backend initial files.
Browse files Browse the repository at this point in the history
  • Loading branch information
xmnlab committed Apr 5, 2018
1 parent 9394436 commit 73becc5
Show file tree
Hide file tree
Showing 9 changed files with 1,318 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ibis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
# pip install ibis-framework[bigquery]
import ibis.bigquery.api as bigquery

with suppress(ImportError):
# pip install ibis-framework[bigquery]
import ibis.mapd.api as mapd

restart_ordering()


Expand Down
Empty file added ibis/mapd/__init__.py
Empty file.
47 changes: 47 additions & 0 deletions ibis/mapd/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# api.py
import pymapd
import ibis.common as com
from ibis.config import options
from ibis.mapd.client import MapDClient
from ibis.mapd.compiler import dialect


def compile(expr, params=None):
"""
Force compilation of expression as though it were an expression depending
on MapD. Note you can also call expr.compile()
Returns
-------
compiled : string
"""
from ibis.mapd.compiler import to_sql
return to_sql(expr, dialect.make_context(params=params))


def verify(expr, params=None):
"""
Determine if expression can be successfully translated to execute on
MapD
"""
try:
compile(expr, params=params)
return True
except com.TranslationError:
return False


def connect(project_id, dataset_id):
"""Create a MapDClient for use with Ibis
Parameters
----------
project_id: str
dataset_id: str
Returns
-------
MapDClient
"""

return MapDClient(project_id, dataset_id)
Loading

0 comments on commit 73becc5

Please sign in to comment.