首页 > 解决方案 > 为什么我的直线自动化脚本没有将数据加载到历史配置单元表?

问题描述

我有一个 shell 脚本,它可以自动执行 beeline 实用程序来执行以下操作:

截断登台表 将数据加载到登台表追加历史表。

到目前为止,一切都很好。我的代码是截断数据并将数据加载到声明表中,但它没有将任何数据附加到历史表中。因为当我发出命令“ 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;"

标签: shellhivebeeline

解决方案


推荐阅读