Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit 3d9b2cb

Browse files
authored
fix: update UDF to support Python 3.8+ AST (#25)
* Identify constants by value type in UDF. * Move tests that don't require BigQuery to unit test directory.
1 parent 57aa1c1 commit 3d9b2cb

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

ibis_bigquery/udf/core.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,20 @@ def visit_BinOp(self, node):
274274
self.visit(left), self.visit(op), self.visit(right)
275275
)
276276

277+
def visit_Constant(self, node):
278+
value = node.value
279+
if value is None:
280+
return 'null'
281+
if isinstance(value, bool):
282+
return 'true' if value else 'false'
283+
if isinstance(value, (int, float, str)):
284+
return repr(value)
285+
raise NotImplementedError(
286+
'{!r} constants not yet implemented'.format(
287+
value.__class__.__name__
288+
)
289+
)
290+
277291
def visit_NameConstant(self, node):
278292
value = node.value
279293
if value is True:

tests/unit/udf/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)