我使用一个字符串,现在我想使用输出,但是由于出现split
-输出被认为是Repeated Sting
,因此也被认为是ARRAY
的错误,所以出现了错误。
我该如何解决?
谢谢
With ex1 as (
SELECT 'test1,test2' as example
),
ex2 as (
SELECT 'test1' as str1, 5 as value)
SELECT *
from
(SELECT split(example,',') as strings
from ex1)
left join
ex2
on str1 = strings
答案 0 :(得分:3)
在使用LEFT JOIN
之前,应先UNNEST
数组:
With ex1 as (
SELECT 'test1,test2' as example
),
ex2 as (
SELECT 'test1' as str1, 5 as value)
SELECT *
from
UNNEST ((SELECT split(example,',') as strings
from ex1
)) as strings
left join
ex2
on str1 = strings
答案 1 :(得分:3)
您需要取消分割结果:
WITH
ex1 AS (
SELECT 'test1,test2' as example),
ex2 AS (
SELECT 'test1' as str1, 5 as value)
SELECT * from
(SELECT * FROM UNNEST((SELECT split(example) FROM ex1)) as strings)
left join
ex2
on str1 = strings