课堂测试03

4、处理结果入库:
将上述统计分析的结果数据保存到 mySQL 数据库中。 第 3 页 共 9 页
5、数据可视化展示:
利用 Echarts 将上述统计结果以图形化展示的方式展现出来:饼图、柱状图、地图、折
线图等。

4.数据入库

text3_1表入库

#1.添加驱动

add jar /usr/local/hive/lib/hive-contrib-3.1.2.jar

add jar /usr/local/hive/lib/mysql-connector-java-8.0.26.jar

 

#2.创建临时函数

CREATE TEMPORARY FUNCTION dboutput AS 'org.apache.hadoop.hive.contrib.genericudf.example.GenericUDFDBOutput'

 

select dboutput('jdbc:mysql://192.168.189.131:3306/hive?useSSL=false','root','123456','INSERT INTO text3_1(day_id, sale_nbr, cnt, round) VALUES (?, ?, ?, ?)',day_id, sale_nbr, cnt, round) from text3_1

 

 

 

 

 

 

text3_2表入库

#1.添加驱动

add jar /usr/local/hive/lib/hive-contrib-3.1.2.jar

add jar /usr/local/hive/lib/mysql-connector-java-8.0.26.jar

 

#2.创建临时函数

CREATE TEMPORARY FUNCTION dboutput AS 'org.apache.hadoop.hive.contrib.genericudf.example.GenericUDFDBOutput'

 

select dboutput('jdbc:mysql://192.168.189.131:3306/hive?useSSL=false','root','123456','INSERT INTO text3_2(day_id, sale_nbr, cnt, round) VALUES (?, ?, ?, ?)',day_id, sale_nbr, cnt, round) from text3_2

 

 

 

text3_3表入库

#1.添加驱动

add jar /usr/local/hive/lib/hive-contrib-3.1.2.jar

add jar /usr/local/hive/lib/mysql-connector-java-8.0.26.jar

 

#2.创建临时函数

CREATE TEMPORARY FUNCTION dboutput AS 'org.apache.hadoop.hive.contrib.genericudf.example.GenericUDFDBOutput'

 

select dboutput('jdbc:mysql://192.168.189.131:3306/hive?useSSL=false','root','123456','INSERT INTO text3_3(day_id, sale_nbr, cnt, round) VALUES (?, ?, ?, ?)',day_id, sale_nbr, cnt, round) from text3_3

 

 

 

5.数据可视化展示

 

 

 

 

 

 

 

 

 

 

 

 

 

posted @ 2021-12-04 19:37  墨夕相拥★  阅读(122)  评论(0编辑  收藏  举报