forked from ibis-project/ibis
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.