大数据

shell 执行 presto 脚本

文 / sptk 来源 / 原创 阅读 / 83 3月前

注意点

环境要求: 相关环境完善例,如:hive prosto集群, 还有你的presto的hive以及mysql的连接器配置完成

1. sql脚本示例

脚本用于从hive导出到mysql, 脚本名字 hive-to-mysql.sql

-- 创建mysql中的表
-- tb_grouping表结构 请查看 http://www.suntao.site/blog/detail/grouping-sets-ce-shi-shu-ju.html/
drop table mysql.test.tb_grouping;  -- 删除测试表
create table  mysql.test.tb_grouping  -- 创建测试表
(
    dt         varchar,   -- varchar 对应的是hive中的string 对应的mysql中的是longText 
    brand       varchar,
    city        varchar,
    sales_sum  int,
    order_num  int,
    group_type  varchar
);

-- 将数据从hive中导入到mysql中
insert into mysql.test.tb_grouping
select dt  ,
       brand,
       city,
       sales_sum,
       order_num,
       group_type
from hive.test.tb_grouping;

2. shell 脚本

这里仅仅是一个简单的使用实例 实际开发我们一般写的是shell的调度脚本,配置调度工具oozie DolphinScheduler airflow 等调度工具完成任务调度

#  presto是指的presto-cli客户端
# --server 指定你的presto服务地址
# -f 指定presto sql脚本
# --execute  可以指定执行的presto sql命令
/export/server/presto/presto --server http://node1:8090  -f  /test/data/hive-to-mysql.sql

0

站点声明:站点主要用于个人技术文章。

冀ICP备19037883号
相关侵权、举报、投诉及建议等,请发E-mail:804330969@qq.com