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

Add BigQuery UDF support #2007

Closed
wants to merge 4 commits into from

Conversation

takbab
Copy link

@takbab takbab commented Jul 21, 2016

Add a field to support BigQuery UDF.
https://cloud.google.com/bigquery/docs/reference/v2/jobs

  • configuration.query.userDefinedFunctionResources[]
  • configuration.query.userDefinedFunctionResources[].inlineCode
  • configuration.query.userDefinedFunctionResources[].resourceUri

(migrated from #1988)

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Jul 21, 2016
@@ -937,6 +938,12 @@ def __init__(self, name, query, client):
reference/v2/jobs#configuration.query.useLegacySql
"""

udf_resources = _TypedProperty(

This comment was marked as spam.

This comment was marked as spam.

@tseaver
Copy link
Contributor

tseaver commented Jul 22, 2016

@takbab I think @dhermes was talking about dropping the use of _TypedProperty in favor of a property implementation which enforces that items in the list are suitable. If we use your class for the items in the list, then the property implementation would look something like:

    @property
    def udf_resources(self):
        """List of user-defined resources.

        :rtype: list of :class:`UdfResource`
        :returns: the list, if set, or None
        """
        return list(self._udf_resources) if self._udf_resources else None

    @udf_resources.setter
    def udf_resources(self, value):
        """Update list of user-defined resources

        :type value: list of :class:`UdfResource`
        :param value: the new list

        :raises: ValueError, ir the items in the list are not all instances of
                 :class:`UdfResource`
        """
        if not all((isinstance(item, UdfResource) for item in value)):
            raise ValueError("pass a list of UdfResource instances")
        self._udf_resources = tuple(value)

@tseaver
Copy link
Contributor

tseaver commented Jul 22, 2016

See #2015 for an alternative.

@dwmclary
Copy link
Contributor

#2015 looks a more like the example from @tseaver but I need to clean up a lint error. What's the advantage to the approach here?

@takbab
Copy link
Author

takbab commented Jul 23, 2016

@tseaver Thanks for the example! I have added the property to QueryJob class.

What can we do?
I just want to use UDF from my app.
#1829

@tseaver
Copy link
Contributor

tseaver commented Jul 27, 2016

@takbab Thanks again for the patch! I merged @dwmclary's version of the feature in #2029, as it looked closer to what I had in mind.

@tseaver tseaver closed this Jul 27, 2016
@takbab
Copy link
Author

takbab commented Jul 28, 2016

I see, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants