bigquery-standard-sql

How to convert an Epoch timestamp to a Date in Standard SQL

纵然是瞬间 提交于 2019-12-05 03:35:20
I didn't find any simple answer to this while I was looking around, so I thought I'd put it up here in case anyone was having the same problem as me with what should have been a trivial issue. I was using ReDash analytics with Google's BigQuery and had turned on Standard SQL in the datasource settings. For the purposes of my query, I needed to convert a timestamp - unix time in milliseconds, as a string - to a Date format so that I could use the DATE_DIFF method. As an example... "1494865480000" to "2017-05-15" The difficulty was that casting and conversion was excessively strict and there

Insert data into BigQuery from a Google Script : Encountered “”

↘锁芯ラ 提交于 2019-12-04 06:06:36
问题 I am trying to import data from a Google Spreadsheet to BigQuery, via Google App Script. I can download data, but I have an error when I try to do INSERT INTO. The error message is Encountered "" at line 1, column 31. [Try using standard SQL (https://cloud.google.com/bigquery/docs/reference/standard-sql/enabling-standard-sql)] Here is my code : function insertRowsInBigQuery(){ var projectId = 'xxx'; var spreadsheet = SpreadsheetApp.getActive(); var sheet = spreadsheet.getSheetByName("EPC");

SQL - Unequal left join BigQuery

£可爱£侵袭症+ 提交于 2019-12-04 05:51:12
问题 New here. I am trying to get the Daily and Weekly active users over time. they have 30 days before they are considered inactive. My goal is to create graph's that can be split by user_id to show cohorts, regions, categories, etc. I have created a date table to get every day for the time period and I have the simplified orders table with the base info that I need to calculate this. I am trying to do a Left Join to get the status by date using the following SQL Query: WITH daily_use AS ( SELECT

Weighted sum of a column vector and a derived bit vector - Version 2

断了今生、忘了曾经 提交于 2019-12-02 20:42:20
问题 We have a table of bid prices and sizes of two buyers. Bid price p with size s means that the buyer is open to buy s number of product at price p . We have a table that contains a few columns (like timestamp, validity flag) together with these four columns: bid prices offered by the two buyers, pA and pB . bid sizes, sA and sB . Our job is to add a new best size column ( bS ) to the table, that returns the size at the best price. If the two buyers have the same price then bS is equal to sA +

Weighted sum of a column vector and a derived bit vector

不打扰是莪最后的温柔 提交于 2019-12-02 19:31:24
问题 We have a table of bid prices and sizes of two buyers. Bid price p with size s means that the buyer is open to buy s number of product at price p . We have a table of four columns: bid prices offered by the two buyers, pA and pB . bid sizes, sA and sB . Our job is to add a new best size column ( bS ) to the table, that returns the size at the best price. If the two buyers have the same price then bS is equal to sA + sB , otherwise, we need to take the bid size of the buyer that offers the

How can I decrypt columns in BigQuery?

风格不统一 提交于 2019-12-02 18:22:44
问题 I have some encrypted columns in BigQuery that I want to decrypt using BigQuery functions. The mechanic used in encrypting them is AES 256. The vector used is encoded in UTF8. The resulting data is encrypted in Base64. What I want to do is decrypt the fields passed to me in BigQuery using functions without going through the trouble of doing extra steps of decrypting them elsewhere and then integrating them back in BigQuery. Note that the encrypted columns which I have access in BigQuery to

Weighted sum of a column vector and a derived bit vector

↘锁芯ラ 提交于 2019-12-02 11:26:01
We have a table of bid prices and sizes of two buyers. Bid price p with size s means that the buyer is open to buy s number of product at price p . We have a table of four columns: bid prices offered by the two buyers, pA and pB . bid sizes, sA and sB . Our job is to add a new best size column ( bS ) to the table, that returns the size at the best price. If the two buyers have the same price then bS is equal to sA + sB , otherwise, we need to take the bid size of the buyer that offers the higher price. An example table with the desired output is below. A simple solution to the problem: SELECT

Weighted sum of a column vector and a derived bit vector - Version 2

一世执手 提交于 2019-12-02 11:25:06
We have a table of bid prices and sizes of two buyers. Bid price p with size s means that the buyer is open to buy s number of product at price p . We have a table that contains a few columns (like timestamp, validity flag) together with these four columns: bid prices offered by the two buyers, pA and pB . bid sizes, sA and sB . Our job is to add a new best size column ( bS ) to the table, that returns the size at the best price. If the two buyers have the same price then bS is equal to sA + sB , otherwise, we need to take the bid size of the buyer that offers the higher price. An example

Insert data into BigQuery from a Google Script : Encountered “”

梦想的初衷 提交于 2019-12-02 09:41:32
I am trying to import data from a Google Spreadsheet to BigQuery, via Google App Script. I can download data, but I have an error when I try to do INSERT INTO. The error message is Encountered "" at line 1, column 31. [Try using standard SQL ( https://cloud.google.com/bigquery/docs/reference/standard-sql/enabling-standard-sql)] Here is my code : function insertRowsInBigQuery(){ var projectId = 'xxx'; var spreadsheet = SpreadsheetApp.getActive(); var sheet = spreadsheet.getSheetByName("EPC"); var data = sheet.getRange(2, 1, sheet.getLastRow() - 1, 2).getValues(); var sqlData = "INSERT INTO ean

SQL - Unequal left join BigQuery

霸气de小男生 提交于 2019-12-02 08:27:07
New here. I am trying to get the Daily and Weekly active users over time. they have 30 days before they are considered inactive. My goal is to create graph's that can be split by user_id to show cohorts, regions, categories, etc. I have created a date table to get every day for the time period and I have the simplified orders table with the base info that I need to calculate this. I am trying to do a Left Join to get the status by date using the following SQL Query: WITH daily_use AS ( SELECT __key__.id AS user_id , DATE_TRUNC(date(placeOrderDate), day) AS activity_date FROM `analysis.Order`