我在频谱外部表的外部架构中创建视图时遇到问题。下面是我用来创建视图的脚本
create or replace view external_schema.test_view as
select id, name from external_schema.external_table with no schema binding;
我得到以下错误
错误:未启用对外部架构中的本地对象的操作。
请帮助创建频谱外部表下的视图
外部表是在外部架构中创建的。Amazon Redshift 外部架构引用 AWS Glue 或 Amazon Athena 中的外部数据目录中的数据库,或 Hive 元存储中的数据库,例如 Amazon EMR。
外部架构在 Redshift 集群中不存在,而是从其源中查找。出于同样的原因,外部表也只是只读的。
因此,您将无法将正在创建的视图绑定到未存储在群集中的架构。您可以在外部表之上创建视图(不带架构绑定子句(,但该视图将驻留在 Redshift 的本地架构中。
TL;DR Redshift 尚不支持在外部架构中创建视图,因此视图只能驻留在 Redshift 的本地架构中。
将external_schema
替换为internal_schema
,如下所示:
create or replace view internal_schema.test_view as
select id, name from external_schema.external_table with no schema binding;