我试图在redshift中运行以下查询
select row_number() over(order by 1) as assignment_tag_id ,
user_id as user_id ,
split_part(t.assignment, ',', numbers.num) as assignment
from cardlytics_test t
join numbers on numbers.num <= regexp_count(t.assignment, ',\\s') + 1
但它引发了错误
Amazon无效操作:函数split_part(字符变化,字符变化,双精度)不存在;
查询有什么问题?
答案 0 :(得分:0)
select row_number() over(order by 1) as assignment_tag_id ,
user_id as user_id ,
split_part(t.assignment, ',',cast (numbers.num as int)) as assignment
from cardlytics_test t
join numbers on numbers.num <= regexp_count(t.assignment, ',\\s') + 1
split_part中的第三个参数(字符串,分隔符,部分)必须是一个整数,并且从错误代码中我假设您正在传递float。
Part - 返回部分的位置(从1开始计算)。必须是大于0的整数。如果part大于字符串部分的数量,SPLIT_PART返回一个空字符串。
如果我做了一个错误的假设请评论,我将重新调整我的答案