在配置单元中插入当前时间戳作为多行插入的一部分

t98cgbkg  于 2021-06-25  发布在  Hive
关注(0)|答案(1)|浏览(241)

我当前正在尝试将多行插入到配置单元中的表中。
我希望在运行时通过timestamp函数添加时间戳。但是,我得到一个错误(见下文)
请注意:有许多行在我的多行插入-我只有粘贴2这里作为一个例子。
插入语句

INSERT INTO kpi01_reference.kp_source_table(event_ref, posting_group, posting_description, posting_account_number, posting_date)
VALUES
    ('P1A', 'AP', 'APM', '31',current_timestamp()),
    ('P1A', 'PA', 'AMP', '3150',current_timestamp())
;

编译语句时出错:失败:semanticexception[error 10293]:无法为insert/values中不支持的tok\ U函数类型的insert values表达式创建临时文件
这是我的表格定义

CREATE TABLE kpi01_reference.kp_source_table(
event_ref string, 
posting_group string, 
posting_description string, 
posting_account_number string, 
posting_date timestamp)
eit6fx6z

eit6fx6z1#

不幸的是,current\u timestamp()函数是一个由error语句引用的tok\u函数,这样的函数在使用value关键字的insert语句中是不允许的。
但是有一条路可以走。必须使用虚拟表并从中选择所需的值。
试试下面,它会工作,改变你的插入相应。

INSERT INTO kpi01_reference.kp_source_table(event_ref, posting_group, posting_description, posting_account_number, posting_date)
select 'P1A', 'AP', 'APM', '31',current_timestamp() from (select 1 ) tmp;

相关问题