无法在红移光谱外部架构中创建视图

cannot create a view in redshift spectrum external schema

我在基于外部频谱 table 的外部架构中创建视图时遇到问题。下面是我用来创建视图的脚本

create or replace view external_schema.test_view as
select id, name from external_schema.external_table with no schema binding;

我遇到错误

错误:未启用对外部架构中本地对象的操作。

请帮助在频谱外部创建视图table

外部表是在外部架构中创建的。 Amazon Redshift 外部架构引用 AWS Glue 或 Amazon Athena 中的外部数据目录中的数据库或 Hive 元存储中的数据库,例如 Amazon EMR。

Redshift 集群中不存在外部架构,而是从其来源中查找的。出于同样的原因,外部表也是只读的。

因此,您将无法将正在创建的视图绑定到未存储在集群中的模式。您可以在外部表之上创建一个视图(WITH NO SCHEMA BINDING 子句),但该视图将驻留在 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;