AnalysisException:不允许操作:Delta 表不支持“CREATE TABLE LIKE”;
AnalysisException: Operation not allowed: `CREATE TABLE LIKE` is not supported for Delta tables;
create table if not exists map_table like position_map_view;
在使用它时出现不允许操作的错误
如documentation中指出的,你需要使用CREATE TABLE AS
,只需在SELECT中使用LIMIT 0
:
create table map_table as select * from position_map_view limit 0;
我没有找到让 CREATE TABLE LIKE
正常工作的简单方法,但我有一个解决方法。在 Databricks 的 DBR 上,你应该能够使用 SHALLOW CLONE 来做类似的事情:
%sql
CREATE OR REPLACE TABLE $new_database.$new_table
SHALLOW CLONE $original_database.$original_table`;
您需要手动替换 $template
s。
备注:
- 这增加了 side-effect 保留 table 内容以备不时之需。
- 具有讽刺意味的是,创建空 table 更难,并且涉及使用自定义代码
操纵 show create table
语句
create table if not exists map_table like position_map_view;
在使用它时出现不允许操作的错误
如documentation中指出的,你需要使用CREATE TABLE AS
,只需在SELECT中使用LIMIT 0
:
create table map_table as select * from position_map_view limit 0;
我没有找到让 CREATE TABLE LIKE
正常工作的简单方法,但我有一个解决方法。在 Databricks 的 DBR 上,你应该能够使用 SHALLOW CLONE 来做类似的事情:
%sql
CREATE OR REPLACE TABLE $new_database.$new_table
SHALLOW CLONE $original_database.$original_table`;
您需要手动替换 $template
s。
备注:
- 这增加了 side-effect 保留 table 内容以备不时之需。
- 具有讽刺意味的是,创建空 table 更难,并且涉及使用自定义代码 操纵
show create table
语句