You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@dwmclaryhttps://github.com/dwmclary if you can point me in the right
direction that would be much appreciated! I'm not sure if I'm doing it
wrong or if this is a bug.
@dwmclaryhttps://github.com/dwmclary if you can point me in the right
direction that would be much appreciated! I'm not sure if I'm doing it
wrong or if this is a bug.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2294
issuecomment-247620692>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/
AA129nhlwM9s79USCQSvlMhZNoUjYlJZks5qqqy9gaJpZM4J5mUy>
fromgcloudimportbigqueryfromgcloud.bigquery.jobimportUDFResourceq="""SELECT * FROM [<dataset>]"""udf="""<udf>"""query=client.run_sync_query(q)
query.udf_resources= [UDFResource("inlineCode", udf)]
query.run() # may be wrong in some places
async w/ inline UDF:
fromgcloudimportbigqueryfromgcloud.bigquery.jobimportUDFResourceq="""SELECT * FROM [<dataset>]"""udf="""<udf>"""dataset=client.dataset(<dataset>)
table=dataset.table(name=<table_name>)
job=client.run_async_query("query", q)
job.udf_resources= [UDFResource("inlineCode", udf)]
job.destination=tablejob.begin() # not right in some examples
async w/ resource uri UDF and destination table:
fromgcloudimportbigqueryfromgcloud.bigquery.jobimportUDFResourceq="""SELECT * FROM [<dataset>]"""udf_uri="gs://some-bucket/js/lib.js"dataset=client.dataset(<dataset>)
table=dataset.table(name=<table_name>)
job=client.run_async_query("query", q)
job.udf_resources= [UDFResource("resourceUri", udf_uri)]
job.destination=tablejob.write_disposition='WRITE_TRUNCATE'# not right in some examplesjob.allow_large_results=True# not documented in examplesjob.flatten_results=False# not documented in examplesjob.begin() # not right in some examples
@1mentat I'm not sure if you looked at my gist from before but I believe I have nearly the same thing as your "sync w/inline UDF" example.
However, that doesn't seem to work for me.
I'm curious if your <udf> example uses bigquery.defineFunction in it?
FYI the UDF in my gist works in the bigquery console.
Sorry, I must have missed it. Too much practice clicking on archive at work.
Inline UDFs through the API require doc headers for types. It's a known issue and was supposed to get fixed a while ago according to the searches I did. I think you need something like:
/**
*
* We define the two parameters, below, and specify the schema of the input row and
* the output row.
*
* @param {{name: string, state: string}} row
* @param function({{upper_name: string,
* state: string}}) emit
*/
@1mentat hmm that doesn't seem to work for me either.
I also tried copying exactly what I have in the UDF editor on the BigQuery console and passing it to query.udf_resources = [UDFResource("inlineCode", INLINE_UDF_CODE)].
Hello,
One of the challenges of maintaining a large open source project is that sometimes, you can bite off more than you can chew. As the lead maintainer of google-cloud-python, I can definitely say that I have let the issues here pile up.
As part of trying to get things under control (as well as to empower us to provide better customer service in the future), I am declaring a "bankruptcy" of sorts on many of the old issues, especially those likely to have been addressed or made obsolete by more recent updates.
My goal is to close stale issues whose relevance or solution is no longer immediately evident, and which appear to be of lower importance. I believe in good faith that this is one of those issues, but I am scanning quickly and may occasionally be wrong. If this is an issue of high importance, please comment here and we will reconsider. If this is an issue whose solution is trivial, please consider providing a pull request.
Activity
daspecster commentedon Sep 15, 2016
@1mentat, sounds like a good idea to me!
I'm not super familiar with BigQuery but I'll give it a go.
I was able to get a UDF working in the console, but I'm struggling to get it working in code.
@tseaver here is my snippet code that I'm experimenting with.
https://github.com/proxy/gist.github.com/daspecster/e26346af9fea67aa6efc0716c11c5956
tseaver commentedon Sep 15, 2016
@daspecster, the feature was added in #2029 by @dwmclary. Maybe Daniel could supply an example of a working inline UDF?
daspecster commentedon Sep 16, 2016
@dwmclary if you can point me in the right direction that would be much appreciated! I'm not sure if I'm doing it wrong or if this is a bug.
1mentat commentedon Sep 16, 2016
There are some other bugs in the docs. I have working code after reading
the source. Will post when I'm at my desk.
On Fri, Sep 16, 2016, 7:50 AM Thomas Schultz notifications@github.com
wrote:
dwmclary commentedon Sep 16, 2016
OK James, one you've got the bugs sorted out, post and I'll sort them out.
On Fri, Sep 16, 2016 at 8:23 AM, James Burns notifications@github.com
wrote:
1mentat commentedon Sep 19, 2016
Sorry for formatting...sync w/ inline udf:
async w/ inline UDF:
async w/ resource uri UDF and destination table:
daspecster commentedon Sep 19, 2016
@1mentat I'm not sure if you looked at my gist from before but I believe I have nearly the same thing as your "sync w/inline UDF" example.
However, that doesn't seem to work for me.
I'm curious if your
<udf>example usesbigquery.defineFunctionin it?FYI the UDF in my gist works in the bigquery console.
1mentat commentedon Sep 19, 2016
Sorry, I must have missed it. Too much practice clicking on archive at work.
Inline UDFs through the API require doc headers for types. It's a known issue and was supposed to get fixed a while ago according to the searches I did. I think you need something like:
immediately above the actual function.
daspecster commentedon Sep 19, 2016
OK thanks! I'll give that a go and let you know how it turns out.
daspecster commentedon Sep 19, 2016
@1mentat hmm that doesn't seem to work for me either.
I also tried copying exactly what I have in the UDF editor on the BigQuery console and passing it to
query.udf_resources = [UDFResource("inlineCode", INLINE_UDF_CODE)].I keep getting
My UDF string
My UDF query...
1mentat commentedon Sep 19, 2016
@daspecster Looking back I'm not sure I got sync working. The same UDF works fine in async (in the sense that it runs until it runs out of resources).
tseaver commentedon Sep 21, 2016
@fhoffa Can you shed some light?
lukesneeringer commentedon Aug 11, 2017
Hello,
One of the challenges of maintaining a large open source project is that sometimes, you can bite off more than you can chew. As the lead maintainer of
google-cloud-python, I can definitely say that I have let the issues here pile up.As part of trying to get things under control (as well as to empower us to provide better customer service in the future), I am declaring a "bankruptcy" of sorts on many of the old issues, especially those likely to have been addressed or made obsolete by more recent updates.
My goal is to close stale issues whose relevance or solution is no longer immediately evident, and which appear to be of lower importance. I believe in good faith that this is one of those issues, but I am scanning quickly and may occasionally be wrong. If this is an issue of high importance, please comment here and we will reconsider. If this is an issue whose solution is trivial, please consider providing a pull request.
Thank you!