最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Making API call as part of UDF in BigQuery - possible? - Stack Overflow

programmeradmin1浏览0评论

I'm wondering if it would be possible to make a api call to the google maps geocoding api within a UDF in BigQuery?

I have Google analytics geo fields such as

{
"geoNetwork_continent": "Europe",
"geoNetwork_subContinent": "Eastern Europe",
"geoNetwork_country": "Russia",
"geoNetwork_region": "Novosibirsk Oblast",
"geoNetwork_metro": "(not set)"
},

And would like to make calls to:

+Amphitheatre+Parkway,+Mountain+View,+CA&key=XXXX

Just wondering if i'd be able to use javascript within the UDF to make an api call for each row in BigQuery.

Would be very powerful and avoid me having to do it in R or Python.

Very much a novice on UDF's so just wanted to ask to see if what i'm suggesting is even possible or not (wondering if external api calls in UDF might be some sort of security concern for whatever reason or if just technically not possible).

Any advice much appreciated.

I'm wondering if it would be possible to make a api call to the google maps geocoding api within a UDF in BigQuery?

I have Google analytics geo fields such as

{
"geoNetwork_continent": "Europe",
"geoNetwork_subContinent": "Eastern Europe",
"geoNetwork_country": "Russia",
"geoNetwork_region": "Novosibirsk Oblast",
"geoNetwork_metro": "(not set)"
},

And would like to make calls to:

https://maps.googleapis./maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=XXXX

Just wondering if i'd be able to use javascript within the UDF to make an api call for each row in BigQuery.

Would be very powerful and avoid me having to do it in R or Python.

Very much a novice on UDF's so just wanted to ask to see if what i'm suggesting is even possible or not (wondering if external api calls in UDF might be some sort of security concern for whatever reason or if just technically not possible).

Any advice much appreciated.

Share Improve this question asked Jan 6, 2016 at 12:34 andrewm4894andrewm4894 1,5584 gold badges17 silver badges40 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 9

Making network calls from your UDF is not permitted. This is due to both security considerations, as well as the fact that queries are (heavily) sharded for execution in BigQuery. Making per-record outbound network connections from the query nodes would DDOS many targets ;)

I think, currently, API calls within UDF are subject of BigQuery UDF limitations
https://cloud.google./bigquery/user-defined-functions#limitations

You can now call remote API using remote functions:

https://cloud.google./bigquery/docs/reference/standard-sql/remote-functions

However, before using this with maps geocoding APIs you have in the example, please check their usage policies, especially the caching and storage policies:

https://developers.google./maps/documentation/geocoding/policies#pre-fetching,-caching,-or-storage-of-content

发布评论

评论列表(0)

  1. 暂无评论