Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigquery udf: len is undefined #1470

Closed
tsdlovell opened this issue Jun 4, 2018 · 9 comments
Closed

bigquery udf: len is undefined #1470

tsdlovell opened this issue Jun 4, 2018 · 9 comments
Labels
bug Incorrect behavior inside of ibis expressions Issues or PRs related to the expression API feature Features or general enhancements
Milestone

Comments

@tsdlovell
Copy link

workaround is to use javascript notation in the udf

len = lambda x: x.length

which will transpile to

let len = ((x) => x.length)
@tsdlovell
Copy link
Author

same is true of zip and probably a lot of other builtins, so maybe this phrasing should change or be caveated

Most of the Python language is supported including classes, functions and generators

@cpcloud
Copy link
Member

cpcloud commented Jun 4, 2018

Most of the language is supported, builtin functions are not part of the language, they are part of the standard library. I'll make that distinction more clear there.

@cpcloud
Copy link
Member

cpcloud commented Jun 4, 2018

Pull requests always welcome to add builtins

@cpcloud
Copy link
Member

cpcloud commented Jun 4, 2018

@tsdlovell Are there any particular builtins you'd like to see other len? Happy to implement any high priority ones alongside len.

@cpcloud cpcloud added this to the 0.14 milestone Jun 4, 2018
@cpcloud cpcloud added bug Incorrect behavior inside of ibis feature Features or general enhancements expressions Issues or PRs related to the expression API bigquery labels Jun 4, 2018
@tsdlovell
Copy link
Author

For enumerate

enumerate = lambda x: x.map(lambda e, i: (e, i))

transpiles to

let enumerate = ((x) => x.map(((e, i) => [e, i])));

@cpcloud
Copy link
Member

cpcloud commented Jun 4, 2018

enumerate yields index, element you probably want to write that as lambda x: x.map(lambda e, i: (i, e))

@cpcloud
Copy link
Member

cpcloud commented Jun 4, 2018

If you are feeling adventurous you can add the rewrites yourself without having to wait on me to implement them. See here for some examples: https://github.com/ibis-project/ibis/blob/master/ibis/bigquery/udf/core.py#L83-L117

@tsdlovell
Copy link
Author

@cpcloud , can you point me to any snippets where a more complicated statement is substituted?

@tsdlovell
Copy link
Author

I might be able to start from visit_ListComp

@cpcloud cpcloud closed this as completed in afd6198 Jun 7, 2018
missing-semicolon pushed a commit to missing-semicolon/ibis that referenced this issue Jun 11, 2018
Closes ibis-project#1470

Author: Phillip Cloud <cpcloud@gmail.com>

Closes ibis-project#1475 from cpcloud/bq-len and squashes the following commits:

a4ca763 [Phillip Cloud] Fix test
504b24a [Phillip Cloud] Flake8
24199a1 [Phillip Cloud] Fix test
eaae183 [Phillip Cloud] ENH: Implement len rewrite for BigQuery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis expressions Issues or PRs related to the expression API feature Features or general enhancements
Projects
None yet
Development

No branches or pull requests

2 participants