为什么我的beeline自动化脚本没有将数据加载到历史配置单元表中?

8qgya5xd  于 2021-06-27  发布在  Hive
关注(0)|答案(0)|浏览(211)

我有一个shell脚本,它自动执行beeline实用程序来执行以下操作:
截断暂存表将数据加载到暂存表并附加历史记录表。
到现在为止,一直都还不错。我的代码正在截断数据并将其加载到stating表中,但它没有将任何数据附加到history表中。因为当我发出命令的时候” select count(*) from history_tbl ". 我在直线上得到了0张唱片。

+------+--+
| _c0  |
+------+--+
| 0    |
+------+--+

令人惊讶的是,当我 select * from history_tbl; “我可以看到实际数据

| "601809196400"|2018-09-19|"default"|"19"|2018-09-24 08:07:36|0.181156|0.514380|0.033541|0.171328|0.035591|0.064005|0|"df"|
"SYSTEM"|"A3"|"LT40"|"OTH"|"1_1day"|"TRADE"|"NA"|"Z_S"|"40-55"|"M"|"2"|0|"8_14"|0|"N"|"Unilateral
 |  left knee"|""|"SYSTEM"|142|0|0.400000|"UN"|1|"9111"|"6"|"S"|53|"M"|23700.000000|"N"|13|"M"||"rico
 "|"zuba"|"BY "|"chris  
 "|"2023-07-30"|0|"PR"  | NULL| NULL| NUL| NULL| NULL | NU

我真的很困惑这个特点。
下面是shell脚本。


# !/bin/bash

timestamp=$(date +%Y-%m-%d-%H:%M:%S:%N)
number=$RANDOM
unix_time=$(date +%Y-%m-%d-%H:%M:%S)
cd path to script

export BEELINE_PREFIX='"jdbc:hive2://server:port,server:port,server:port/;serviceDiscoveryMode=zookeeper;zookeeperNamespace=hiveserver2;principal=hive/server@hello.COM"'
beeline -u $BEELINE_PREFIX -e "use next;"

echo "truncating the staging table tbl..."
beeline -u $BEELINE_PREFIX -e  "TRUNCATE TABLE next.tbl;"

echo "Loading the data in staging table  tbl"
beeline -u $BEELINE_PREFIX -e "LOAD DATA LOCAL INPATH '/path/tbl' INTO TABLE next.tbl;"

echo "Appending the data into history table HIST_tbl.."
beeline -u $BEELINE_PREFIX -e "insert into table next.HIST_tbl select *,'$unix_time','$number' from next.tbl;"

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题