-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'ibis-project/master'
- Loading branch information
Showing
33 changed files
with
699 additions
and
360 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import fnmatch | ||
import os | ||
import sys | ||
|
||
collect_ignore = ['setup.py'] | ||
|
||
if sys.version_info.major == 2: | ||
this_directory = os.path.dirname(__file__) | ||
bigquery_udf = os.path.join(this_directory, 'ibis', 'bigquery', 'udf') | ||
for root, _, filenames in os.walk(bigquery_udf): | ||
for filename in filenames: | ||
if fnmatch.fnmatch(filename, '*.py'): | ||
collect_ignore.append(os.path.join(root, filename)) |
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
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
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,68 @@ | ||
from multipledispatch import Dispatcher | ||
|
||
import ibis.expr.datatypes as dt | ||
|
||
|
||
class TypeTranslationContext(object): | ||
"""A tag class to allow alteration of the way a particular type is | ||
translated. | ||
Notes | ||
----- | ||
This is used to translate INT64 types to FLOAT64 when INT64 is used in the | ||
definition of a UDF. | ||
""" | ||
__slots__ = () | ||
|
||
|
||
ibis_type_to_bigquery_type = Dispatcher('ibis_type_to_bigquery_type') | ||
|
||
|
||
@ibis_type_to_bigquery_type.register(dt.DataType) | ||
def trans_default(t): | ||
return ibis_type_to_bigquery_type(t, TypeTranslationContext()) | ||
|
||
|
||
@ibis_type_to_bigquery_type.register(dt.Floating, TypeTranslationContext) | ||
def trans_float64(t, context): | ||
return 'FLOAT64' | ||
|
||
|
||
@ibis_type_to_bigquery_type.register(dt.Integer, TypeTranslationContext) | ||
def trans_integer(t, context): | ||
return 'INT64' | ||
|
||
|
||
@ibis_type_to_bigquery_type.register(dt.Array, TypeTranslationContext) | ||
def trans_array(t, context): | ||
return 'ARRAY<{}>'.format( | ||
ibis_type_to_bigquery_type(t.value_type, context)) | ||
|
||
|
||
@ibis_type_to_bigquery_type.register(dt.Struct, TypeTranslationContext) | ||
def trans_struct(t, context): | ||
return 'STRUCT<{}>'.format( | ||
', '.join( | ||
'{} {}'.format( | ||
name, | ||
ibis_type_to_bigquery_type(dt.dtype(type), context) | ||
) for name, type in zip(t.names, t.types) | ||
) | ||
) | ||
|
||
|
||
@ibis_type_to_bigquery_type.register(dt.Date, TypeTranslationContext) | ||
def trans_date(t, context): | ||
return 'DATE' | ||
|
||
|
||
@ibis_type_to_bigquery_type.register(dt.Timestamp, TypeTranslationContext) | ||
def trans_timestamp(t, context): | ||
if t.timezone is not None: | ||
raise TypeError('BigQuery does not support timestamps with timezones') | ||
return 'TIMESTAMP' | ||
|
||
|
||
@ibis_type_to_bigquery_type.register(dt.DataType, TypeTranslationContext) | ||
def trans_type(t, context): | ||
return str(t).upper() |
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 |
---|---|---|
@@ -1,4 +1 @@ | ||
try: | ||
from ibis.bigquery.udf.api import udf # noqa: F401 | ||
except ImportError: | ||
pass # BigQuery UDFs are not supported in Python 2 | ||
from ibis.bigquery.udf.api import udf # noqa: F401 |
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
Oops, something went wrong.