简体   繁体   English

DBT - 语法错误:应为“(”或关键字 SELECT 或关键字 WITH 但关键字 CREATE 位于

[英]DBT - Syntax error: Expected "(" or keyword SELECT or keyword WITH but got keyword CREATE at

I am trying to make an sql file in dbt in order to update models with a new column我正在尝试在 dbt 中创建一个 sql 文件,以便使用新列更新模型

{{
    config(materialized='table'
    , retain_previous_version_flg=false
    , migrate_data_over_flg=true
)
}}

CREATE OR REPLACE TABLE {{ ref ('my_table') }} (
SELECT *, new_columns_ts TIMESTAMP
);

Is there a way to use CREATE directly rather than having to use SELECT or WITH clause?有没有办法直接使用 CREATE 而不必使用 SELECT 或 WITH 子句?

Syntax error: Expected "(" or keyword SELECT or keyword WITH but got keyword CREATE at [16:1]

In this particular case, you don't need to use the statement CREATE OR REPLACE TABLE, to create a materialized table.在这种特殊情况下,您不需要使用语句 CREATE OR REPLACE TABLE 来创建物化表。 You only need to write the SELECT statement.只需要写SELECT语句即可。

There are no create or replace statements written in model statements. model语句中没有写create或replace语句。 This means that dbt does not offer methods for issuing CREATE TABLE statements which can be used for source tables.这意味着 dbt 不提供发出可用于源表的 CREATE TABLE 语句的方法。

You can see this example .你可以看到这个例子

{{
    config(materialized='table'
    , retain_previous_version_flg=false
    , migrate_data_over_flg=true
)
}}


SELECT *, new_columns_ts TIMESTAMP from ‘dataset.table’

You can see this option using SQL .您可以使用 SQL 查看此选项

CREATE OR REPLACE TABLE dataset.table (
SELECT *, new_columns_ts TIMESTAMP from ‘dataset.table’
);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 语法错误:应为“(”或“,”或关键字 SELECT 但脚本结束 - Syntax error: Expected "(" or "," or keyword SELECT but got end of script 语法错误:应为“)”但在 [2:93] 处获得了关键字 NEW - Syntax error: Expected ")" but got keyword NEW at [2:93] 使用 with 子句时出错我收到消息“语法错误:预期的关键字 AS 但在 [7:14] 得到了“(” - Error using the with clause I received message " Syntax error: Expected keyword AS but got "(" at [7:14]" 错误代码 BIG QUERY:预期输入结束但得到关键字 SELECT bigquery - Error code BIG QUERY: Expected end of input but got keyword SELECT bigquery 错误:sink() 得到了一个意外的关键字参数 'parent' - Error: sink() got an unexpected keyword argument ‘parent’ 我有语法错误:意外的关键字 SET - I have Syntax error: Unexpected keyword SET AirFlow Python 运算符错误:得到一个意外的关键字参数 'conf' - AirFlow Python operator error: got an unexpected keyword argument 'conf' CREATE OR ALTER TABLE 因“关键字‘TABLE’附近的语法不正确”而失败 - CREATE OR ALTER TABLE is failing with "Incorrect syntax near the keyword 'TABLE'" 出现语法错误:运行“立即执行”时意外的关键字 END - Getting Syntax Error: Unexpected keyword END while running `Execute Immediate` Ansible - 得到一个意外的关键字参数 - check_invalid_arguments - Ansible - got an unexpected keyword argument - check_invalid_arguments
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM