我想在hql中生成使用beeline运行的动态表名。
在db2中,我可以使用||实现此要求。例如,使用year生成表名’as400.trxfintrx_’||年(…
如果我理解它是正确的,您希望表名称是参数化的,
为此你可以使用hive变量,
create table dbName.table1_${hivevar:yearMonthDate} ( c1 int, c2 int ) stored as orc tblproperties('ZLIB'); $ hive -f test_create_table.hql --hivevar yearMonthDate=20190215 OK Time taken: 1.149 seconds $ hive Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases. hive> use dbname; OK Time taken: 0.726 seconds hive> desc table1_20190215; OK c1 int c2 int Time taken: 0.302 seconds, Fetched: 2 row(s)
你可以参考 https://cwiki.apache.org/confluence/display/Hive/LanguageManual+VariableSubstitution
从beeline终端,您无法定义任何设置参数值的函数,然后在查询中使用它们。
希望这可以帮助