如何解决 impala insert with select 查询错误?
How to solve impala insert with select query error?
我想在 service_log table 中插入一行,id 值为 max+1。
insert into bi_dev.service_logs values (select nvl(max(id),0) + 1 as count from bi_dev.service_logs , 1, now(), 0, "Error")
但这给了我以下错误;
AnalysisException: Syntax error in line 29:undefined: ..._dev.service_logs values (select nvl(max(id),0) + 1 as... ^ Encountered: SELECT Expected: CASE, CAST, DEFAULT, EXISTS, FALSE, IF, INTERVAL, NOT, NULL, REPLACE, TRUNCATE, TRUE, IDENTIFIER CAUSED BY: Exception: Syntax error.
我该如何解决这个问题?
这应该适用于大多数 SQL 方言:
insert into bi_dev.service_logs
select nvl(max(id),0) + 1 as count,
, 1
, now()
, 0
, "Error"
from bi_dev.service_logs
我想在 service_log table 中插入一行,id 值为 max+1。
insert into bi_dev.service_logs values (select nvl(max(id),0) + 1 as count from bi_dev.service_logs , 1, now(), 0, "Error")
但这给了我以下错误;
AnalysisException: Syntax error in line 29:undefined: ..._dev.service_logs values (select nvl(max(id),0) + 1 as... ^ Encountered: SELECT Expected: CASE, CAST, DEFAULT, EXISTS, FALSE, IF, INTERVAL, NOT, NULL, REPLACE, TRUNCATE, TRUE, IDENTIFIER CAUSED BY: Exception: Syntax error.
我该如何解决这个问题?
这应该适用于大多数 SQL 方言:
insert into bi_dev.service_logs
select nvl(max(id),0) + 1 as count,
, 1
, now()
, 0
, "Error"
from bi_dev.service_logs