Hive 在配置单元中插入当前时间戳作为多行插入的一部分
我目前正在尝试将多行插入到配置单元中的表中 我希望在运行时通过timestamp函数添加时间戳。但我得到一个错误(见下文) 请注意:有很多行在我的多行插入-我只有粘贴2这里作为一个例子 插入语句Hive 在配置单元中插入当前时间戳作为多行插入的一部分,hive,insert,timestamp,Hive,Insert,Timestamp,我目前正在尝试将多行插入到配置单元中的表中 我希望在运行时通过timestamp函数添加时间戳。但我得到一个错误(见下文) 请注意:有很多行在我的多行插入-我只有粘贴2这里作为一个例子 插入语句 INSERT INTO kpi01_reference.kp_source_table(event_ref, posting_group, posting_description, posting_account_number, posting_date) VALUES ('P1A',
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[错误10293]:无法为insert/values中不支持的TOK_函数类型的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)
不幸的是,current_timestamp()函数是错误语句所指的TOK_函数,在使用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;