google-bigquery

jsonpath in bigquery doesn't support @ for filter. Suggestions for alternatives?

孤者浪人 提交于 2020-01-06 06:25:47
问题 At https://jsonpath.curiousconcept.com/ with this JSON document: [{ "key": "name", "value": "john doe" }, { "key": "age", "value": "8" }, { "key": "gender", "value": "male" }] I can use JsonPath expression $[?(@.key=="age")].value to extract the value ["8"] which is what I want. However, when I try and use that same JsonPath in bigquery like so: select JSON_EXTRACT_SCALAR('[{"key": "name","value": "john-doe"}, {"key": "age","value": "8"}, {"key": "gender","value": "male"}]', '$[?(@.key=="age"

Querying data from BigQuery and return a single data into Google AppMaker

末鹿安然 提交于 2020-01-06 06:19:44
问题 From my previous question here, I think it is the problem to my server-script function that queries the data from BigQuery. Following are my code to queries HOD email base on requester email address. //To fetch requester's HOD email address function BigQueryGetEmail(emailRequester){ // Replace this value with the project ID listed in the Google // Cloud Platform project. var projectId = 'xxxxxx-xxx-stg'; query = '#standardSQL \n SELECT SUPV_EMAIL_A FROM `xxxxx-xxx-stg.xxxxx.vw_HOD_email`

Need partition by three field and ranking

柔情痞子 提交于 2020-01-06 05:52:06
问题 I have a query which fetches result by partitioning counterid, status, source as rank. Using query as select ch.* except (seqnum, seqnum_s), row_number() over (partition by counter_id, status,source, (seqnum_s - seqnum) order by transaction_time ) as ranking from (select ch.*, row_number() over (partition by counter_id order,status by transaction_time) as seqnum, row_number() over (partition by counter_id, status,source order by transaction_time) as seqnum_s from counter_history ch ) ch; but

How do I take out data from an event for multiple parameters with value of one parameter being the same in the event

Deadly 提交于 2020-01-06 05:27:04
问题 Take for example, event_dim.name = "Start_Level" event_dim.params.key = "Chapter_Name" event_dim.params.value.string_value = "chapter_1" (or "chapter_2" or "chapter_3" and so on) event_dim.params.key = "Level" event_dim.params.value.int_value = 1 or 2 or 3 or 4 and so on event_dim.params.key = "Opening_Balance" event_dim.params.value = 1000 or 1200 or 300 or so on How do I take out the data if I want to: - Look at unique users who've played "Level" only for event_dim.params.string_value =

Can we create dynamic partition in Big Query as in Hive?

流过昼夜 提交于 2020-01-06 04:51:11
问题 I wanted all my data stored in Buckets (ex: /bucket/project/odate/odate_cust.txt) to be loaded in the table in Big Query which is DAY partitioned? Do I need to import one by one file and load or I can load directly into multiple partition. **bq mk --time_partitioning_type=DAY market.cust custid:string,grp:integer,odate:string** 回答1: Currently, you would need to specify the partition (using the $ decorator syntax) for each load to put it in the corresponding partition. Otherwise, BigQuery will

Loading a Lot of Data into Google Bigquery from Python

孤人 提交于 2020-01-06 04:10:11
问题 I've been struggling to load big chunks of data into bigquery for a little while now. In Google's docs, I see the insertAll method, which seems to work fine, but gives me 413 "Entity too large" errors when I try to send anything over about 100k of data in JSON. Per Google's docs, I should be able to send up to 1TB of uncompressed data in JSON. What gives? The example on the previous page has me building the request body manually instead of using insertAll, which is uglier and more error prone

How to safely inject parameter into string DB query java?

北城以北 提交于 2020-01-06 03:49:08
问题 I have this bigQuery example code: List<TableRow> rows = executeQuery( "SELECT TOP(corpus, 10) as title, COUNT(*) as unique_words Where country = 'USA' " + + "FROM [publicdata:samples.shakespeare]", bigquery, PROJECT_ID); If i want to safely inject the country to that string how can i do that? I want to avoid the risk of sql injection and this is risky: public void foo(String countryParam) { List<TableRow> rows = executeQuery( "SELECT TOP(corpus, 10) as title, COUNT(*) as unique_words Where

How can I change maximumBillingTier?

别来无恙 提交于 2020-01-06 03:47:24
问题 I am testing BigQuery tables and I saw that I can modify the maximumBillingTier in order to require a large amount of resources to process per byte of source data but it is not clear to me how can I modify this filed. Can you show an example? how can I modify this field? It is possible to change this value per query? as mentioned here Can I also change in on WEB UI? I found no document showing how can this be accomplished 回答1: To run the query at a higher pricing tier, pass a new value for

How to name a table column including dot?

眉间皱痕 提交于 2020-01-06 03:40:14
问题 I noticed that if I rename a column name include . , e.g., device.name , it would be automatically converted to device_name in BigQuery. select Device device.name from mydataset.DeviceTable limit 10 Is there anyway I can use dot in column names? 回答1: Dots are reserved for indicating nesting. You can import nested data via json import (e.g. {device: {name "foo"}} ). Query results get flattened, and so dots in query results will get turned to underscores. 来源: https://stackoverflow.com/questions

Response too large to return with LIMIT 1;

三世轮回 提交于 2020-01-06 03:22:22
问题 I was playing with bigquery and ran into a problem, my Query was: SELECT * FROM ( SELECT a.title, a.counter , MAX(b.num_characters) as max FROM ( SELECT title, count(*) as counter FROM publicdata:samples.wikipedia GROUP EACH BY title ORDER BY counter DESC LIMIT 10 ) a JOIN (SELECT title,num_characters FROM publicdata:samples.wikipedia ) b ON a.title = b.title GROUP BY a.title, a.counter) LIMIT 1; Although this is valid, I'm getting response too large to return. The first Subquery is running