且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

BigQuery:SPLIT()只返回一个值

更新时间:2022-10-19 18:52:01

现在我明白你希望他们在不同的栏目中。



您提供的查询的替代方法:

  SELECT FIRST SPLIT(path,'/'))part1,
NTH(2,SPLIT(path,'/'))part2,
NTH(3,SPLIT(path,'/'))part3
FROM(SELECT/ a / b / aaaa?cpath)

NTH(X,SPLIT(s))将提供SPLIT中的第X个值。 FIRST(s) NTH(1,s)


相同

I have a page URL column components of which are delimited by /. I tried to run the SPLIT() function in BigQuery but it only gives the first value. I want all values in specific columns.

I don't understand how to use the Regexp_extract() example mentioned in Split string into multiple columns with bigquery.

I need something similar to REGEX_SPLIT_TO_TABLE(<String>, <DELIMITER>) which converts a single string into multiple columns.

Query:

SELECT PK, 
DATE(TIMESTAMP(CONCAT(SUBSTR(date,1,4),'-',SUBSTR(date,5,2),'-',SUBSTR(date,7,2),' 00:00:00'))) as visit_date,
hits_page_pagePath,
split(hits_page_pagePath,'/')
FROM [Intent.All2mon] limit 100

Now I understand you want them in different columns.

An alternative to the query you provided:

SELECT FIRST(SPLIT(path, '/')) part1,
       NTH(2, SPLIT(path, '/')) part2,
       NTH(3, SPLIT(path, '/')) part3
FROM (SELECT "/a/b/aaaa?c" path)

NTH(X, SPLIT(s)) will provide the Xth value from the SPLIT. FIRST(s) is the same as NTH(1, s)