首页 > 解决方案 > 在配置单元中创建一个带有时间戳作为注释的表

问题描述

我想在 hive 中创建一个表,里面的注释包括创建日期(current_timestamp 函数)。像这样的东西:

CREATE TABLE IF NOT EXISTS ex.tb_test ( field1 int, field2 String) COMMENT current_timestamp STORED AS TEXTFILE;

但它返回错误:ILED: ParseException line 2: 8 mismatched input 'current_timestamp' expecting StringLiteral near 'COMMENT'

你知道有什么方法可以在评论中添加表格的创建日期吗?

标签: hivecommentscreate-tablebeelinehiveddl

解决方案


表 DDL 中不支持函数。您可以将预先计算的时间戳作为--hiveconf参数传递并使用例如:( comment '${hiveconf:ts}'它应该被引用),这样的参数将在命令执行之前被解析为字符串文字。

BTW Hive 存储 CreateTime。

describe formatted table_name命令输出CreateTime以及其他表信息。


推荐阅读