google-bigquery

Check and map IP address to subnet lookup table with SQL

☆樱花仙子☆ 提交于 2020-03-01 04:34:42
问题 I have a table that shows IP addresses assigned to equipment belonging to a customer. This table is used to measure user's activity and performance and generated on a regular basis. I would like to map the IP addresses of these customers to customer ID or name. Due to size and multiple IP addresses that can be assigned to the same customer we have to use subnet instead of individual IP addresses. The report table contains an IPaddress field and the subnet mapping table is something like below

Finding Substring in Bigquery

孤人 提交于 2020-02-27 22:40:55
问题 How to find substrings in Bigquery? I couldn't find any function which supports firing queries like 'Substring(Column_Name,3,7)'. Is there any way out to achieve the same functionality in Bigquery? 回答1: #standardSQL WITH yourTable AS ( SELECT 'Finding Substring in Bigquery' AS Column_Name ) SELECT SUBSTR(Column_Name, 9, 12) FROM yourTable So SUBSTR(value, position [, length]) is for you to use See String Functions for more 回答2: You can use substr e.g. substr(Column_Name,3,7) 来源: https:/

How to create a new column through a old one with REGEX in BigQuery?

﹥>﹥吖頭↗ 提交于 2020-02-26 01:01:51
问题 I would like to create a new column through an old one. I have this column: name . It's a String column. I have this kind of data: ALUMNNAME_SURNAME_CLASS_UNIVERSITY_YEAR_(16/09 - 22/09) I would like to create new columns split each _ . In Google Sheets, I know how to do it ( INDEX(SPLIT(C2:C;"_");0;1... ) but how can I do it in BigQuery ? I understand it's something like this: SELECT name, REGEXP_EXTRACT(name, regex) AS Name, REGEXTRACT(name, regex) AS Surname, ... Could you help me to

How to create a new column through a old one with REGEX in BigQuery?

限于喜欢 提交于 2020-02-26 00:59:32
问题 I would like to create a new column through an old one. I have this column: name . It's a String column. I have this kind of data: ALUMNNAME_SURNAME_CLASS_UNIVERSITY_YEAR_(16/09 - 22/09) I would like to create new columns split each _ . In Google Sheets, I know how to do it ( INDEX(SPLIT(C2:C;"_");0;1... ) but how can I do it in BigQuery ? I understand it's something like this: SELECT name, REGEXP_EXTRACT(name, regex) AS Name, REGEXTRACT(name, regex) AS Surname, ... Could you help me to

How to create a new column through a old one with REGEX in BigQuery?

老子叫甜甜 提交于 2020-02-26 00:57:16
问题 I would like to create a new column through an old one. I have this column: name . It's a String column. I have this kind of data: ALUMNNAME_SURNAME_CLASS_UNIVERSITY_YEAR_(16/09 - 22/09) I would like to create new columns split each _ . In Google Sheets, I know how to do it ( INDEX(SPLIT(C2:C;"_");0;1... ) but how can I do it in BigQuery ? I understand it's something like this: SELECT name, REGEXP_EXTRACT(name, regex) AS Name, REGEXTRACT(name, regex) AS Surname, ... Could you help me to

Does BigQuery support “execute immediate” command to run dynamic query?

一笑奈何 提交于 2020-02-25 01:25:33
问题 I can code like this in Oracle to create tables dynamically using " execute immediate 'sql query..' " command. create or replace function make_a_table1(p_table_name varchar2, p_column_name varchar2, p_data_type varchar2) return varchar2 is var varchar2(150); sydt varchar2(30); pragma autonomous_transaction; begin select to_char(sysdate,'HH24_MI_SS') into sydt from dual; dbms_output.put_line(sydt); var :='create table '||p_table_name||'_'||sydt||' ( '||p_column_name||' '||p_data_type||')';

BigQuery UI - Datasets missing

。_饼干妹妹 提交于 2020-02-24 04:31:35
问题 I have a weird issue with my BigQuery UI (going on https://bigquery.cloud.google.com/queries/my-project-name). I don't know why, but I see no datasets for my projects, when I'm fully aware they exist. My code can still hit these datasets and their tables. There is just no way for me to see them. In the UI itself, I can still query them if I type the whole query by hand, but being able to see my structure for my schema could be helpful. When I check my network tab in the developer tools on

How to make requests in third party APIs and load the results periodically on google BigQuery? What google services should I use?

断了今生、忘了曾经 提交于 2020-02-23 04:58:59
问题 I need to get the data from a third party API and ingest it in google BigQuery. Perhaps, I need to automate this process through google services to do it periodically. I am trying to use Cloud Functions, but it needs a trigger. I have also read about App Engine, but I believe it is not suitable for only one function to make pull requests. Another doubt is: do I need to load the data into cloud storage or can I load it straight to BigQuery? Should I use Dataflow and make any configuration? def

REGEXP_REPLACE pattern has to be const? Comparing strings in BigQuery

痴心易碎 提交于 2020-02-23 04:09:55
问题 I'm trying to measure similarity between strings using Dice's Coefficient (aka Pair Similarity) in BigQuery. For a second I thought that I can do that using just standard functions. Suppose I need to compare "gana" and "gano". Then I would "cook" these two strings upfront into 'ga|an|na' and 'ga|an|no' (lists of 2-grams) and do this: REGEXP_REPLACE('ga|an|na', 'ga|an|no', '') Then based on change in length I can calculate my coeff. But once applied to the table I get: REGEXP_REPLACE second

REGEXP_REPLACE pattern has to be const? Comparing strings in BigQuery

谁说胖子不能爱 提交于 2020-02-23 04:08:19
问题 I'm trying to measure similarity between strings using Dice's Coefficient (aka Pair Similarity) in BigQuery. For a second I thought that I can do that using just standard functions. Suppose I need to compare "gana" and "gano". Then I would "cook" these two strings upfront into 'ga|an|na' and 'ga|an|no' (lists of 2-grams) and do this: REGEXP_REPLACE('ga|an|na', 'ga|an|no', '') Then based on change in length I can calculate my coeff. But once applied to the table I get: REGEXP_REPLACE second