google-bigquery

Can query tables from different datasets in BigQuery

ぃ、小莉子 提交于 2021-01-01 10:15:15
问题 In Google BigQuery, can a query joins two tables in different datasets? say If I want to join these two tables, what should I do? dataset1:table1 and dataset2:table2 Thank you 回答1: #standardSQL SELECT <fields list> FROM `project.dataset1.table1` t1 JOIN `project.dataset2.table2` t2 ON t1.id = t2.id see more about JOINs in documentation 来源: https://stackoverflow.com/questions/49327613/can-query-tables-from-different-datasets-in-bigquery

BigQuery: convert epoch to TIMESTAMP

末鹿安然 提交于 2020-12-29 05:34:48
问题 I'm trying to range-join two tables, like so SELECT * FROM main_table h INNER JOIN test.delay_pairs d ON d.interval_start_time_utc < h.visitStartTime AND h.visitStartTime < d.interval_end_time_utc where h.visitStartTime is an INT64 epoch and d.interval_start_time_utc and d.interval_end_time_utc are proper TIMESTAMP s. The above fails with No matching signature for operator < for argument types: TIMESTAMP, INT64. Supported signature: ANY < ANY Neither wrapping h.visitStartTime in TIMESTAMP()

Case when over partition by applied per row

偶尔善良 提交于 2020-12-27 06:09:09
问题 My table looks like this: |--------|--------|--------|--------|---------|---------| | num_1 | num_2 | num_3 |level_1 | level_2 | level_3 | |--------|--------|--------|--------|---------|---------| | 1111 | 3333 | 4444 | false | false | false | |--------|--------|--------|--------|---------|---------| | 1111 | 3333 | 5555 | false | false | false | |--------|--------|--------|--------|---------|---------| | 1111 | 6666 | null | false | false | false | |--------|--------|--------|--------|------

Case when over partition by applied per row

南楼画角 提交于 2020-12-27 06:08:44
问题 My table looks like this: |--------|--------|--------|--------|---------|---------| | num_1 | num_2 | num_3 |level_1 | level_2 | level_3 | |--------|--------|--------|--------|---------|---------| | 1111 | 3333 | 4444 | false | false | false | |--------|--------|--------|--------|---------|---------| | 1111 | 3333 | 5555 | false | false | false | |--------|--------|--------|--------|---------|---------| | 1111 | 6666 | null | false | false | false | |--------|--------|--------|--------|------

Case when over partition by applied per row

做~自己de王妃 提交于 2020-12-27 06:04:55
问题 My table looks like this: |--------|--------|--------|--------|---------|---------| | num_1 | num_2 | num_3 |level_1 | level_2 | level_3 | |--------|--------|--------|--------|---------|---------| | 1111 | 3333 | 4444 | false | false | false | |--------|--------|--------|--------|---------|---------| | 1111 | 3333 | 5555 | false | false | false | |--------|--------|--------|--------|---------|---------| | 1111 | 6666 | null | false | false | false | |--------|--------|--------|--------|------

Is there a way to parse XML tags in BigQuery Standard SQL?

﹥>﹥吖頭↗ 提交于 2020-12-23 08:19:32
问题 I have read that it's a bad idea to parse XML/HTML using regular expressions. The alternative suggestion is to use an XML parser. Does one exist in the BigQuery Standard SQL library? 回答1: Here is the documentation to how to use Javascript UDFs in BigQuery like Elliot has mentioned. https://cloud.google.com/bigquery/docs/reference/standard-sql/user-defined-functions I imagine the UDF might look something like CREATE TEMPORARY FUNCTION XML(x STRING) RETURNS STRING LANGUAGE js AS """ var data =

Is there a way to parse XML tags in BigQuery Standard SQL?

巧了我就是萌 提交于 2020-12-23 08:17:52
问题 I have read that it's a bad idea to parse XML/HTML using regular expressions. The alternative suggestion is to use an XML parser. Does one exist in the BigQuery Standard SQL library? 回答1: Here is the documentation to how to use Javascript UDFs in BigQuery like Elliot has mentioned. https://cloud.google.com/bigquery/docs/reference/standard-sql/user-defined-functions I imagine the UDF might look something like CREATE TEMPORARY FUNCTION XML(x STRING) RETURNS STRING LANGUAGE js AS """ var data =

Custom SQL using Spark Big Query Connector

本秂侑毒 提交于 2020-12-15 05:34:05
问题 I have some custom sql to read the data from BigQuery. How can I execute that? I tried using option as query but it is not working. It is ignoring the query option and reading the full table. Dataset<Row> testDS = session.read().format("bigquery") //.option("table", <TABLE>) .option("query",<QUERY>) .option("project", <PROJECT_ID>) .option("parentProject", <PROJECT_ID>) .load(); 回答1: That's because the query option is not available in the connector. See https://github.com/GoogleCloudDataproc

BigQuery: How do I add a field to a REPEATED record?

孤街浪徒 提交于 2020-12-15 05:33:19
问题 I've got a table in Google BigQuery that consists of a few fields, then a REPEATED record which may contain one or more objects. I want to create a new table with an extra field in the REPEATED data, and copy my original data into the new table, populating the new field with the output of GENERATE_UUID() so there is one unique identifier per REPEATED line of data. I had a similar question at How do I copy from one BigQuery Table to another when the target contains REPEATED fields? but I don't

Custom SQL using Spark Big Query Connector

那年仲夏 提交于 2020-12-15 05:32:46
问题 I have some custom sql to read the data from BigQuery. How can I execute that? I tried using option as query but it is not working. It is ignoring the query option and reading the full table. Dataset<Row> testDS = session.read().format("bigquery") //.option("table", <TABLE>) .option("query",<QUERY>) .option("project", <PROJECT_ID>) .option("parentProject", <PROJECT_ID>) .load(); 回答1: That's because the query option is not available in the connector. See https://github.com/GoogleCloudDataproc