我已经创建了一个用于访问存储在S3中的PARQUET中的记录的"虚拟"表.我已经使用以下查询在"虚拟"表的顶部创建了一个"DUMMY_FLATEED"视图
CREATE OR REPLACE VIEW dummy_flattened AS
select
deviceid
, a.postid
, a.craterid
, a.posttype
, a.category
FROM dummy cross join UNNEST(postlist) as t(a)
邮寄列表行的示例:
[{类别=[{id=1,名称=舞蹈}],craterid=1,postid=1,posttype=a}, {类别=[{2,名称=舞蹈}],陨石坑ID=2,位置ID=2,张贴类型=b}]
现在,当我try 使用查询在Dummy_Flated视图之上创建一个视图时
create or replace view test as select distinct deviceid from dummy_flattened limit 100
雅典娜给了我一个错误:
Failed analyzing stored view 'logs.dummy_flattened': line
19:12: Column alias list has 1 entries but 't' has 4 columns available
但我可以使用上面提到的相同查询来查看结果
select distinct deviceid from dummy_flattened limit 100
但是,当我不包括.postid、.craterid时,在创建Dummy_Flated时,我可以成功地创建测试视图. 然而,我想不出如何在包括postid、craterid、postype的平面化视图之上创建一个视图,而不会遇到错误.
在过go 的几个小时里,我一直在try 多种组合,但没有成功.
A few of the combinations i tried while creating flattened view
1. select deviceid,t.* as (a) FROM dummy cross join UNNEST(postlist) as t
2. select deviceid,(t.a.*) as (c,d,e,f) FROM dummy cross join UNNEST(postlist) as t(a)
3. And the one i mentioned above at the beginning
我想知道我是否遗漏了什么,或者我们是否可以不在未嵌套的记录上创建视图.我一直在参考堆栈溢出中的多个文档和其他类似的问题,但没有找到任何东西.作为最后的手段,我贴出了这篇文章