Hue 导出数据到 mysql

因工作需要,要将hue上的数据导出到mysql,方便做展示。但是存储人手不足,只好自己上了。

大致流程是,在hue上建一个工作流即可,下面讲一下详细的步骤。

Step 1: 建 Workflow

  • 点击[Workflows]->[Editors]->[Workflows]
  • 点击[Create]
  • 添加[Hive Script]
example_hive_script.sql

set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
create table if not exists dst.test_table
(a bigint, b bigint) partitioned by (day string);

insert overwrite table dst.test_table partition(day="${day}")

SELECT a,
       max(b),
FROM src.test_table
WHERE DAY="${day}"
GROUP BY a
ORDER BY a
  • 添加[Sqoop command]
example Sqoop command

export --connect jdbc:mysql://ip:port/test_db --username name --password passwd --table test_table --fields-terminated-by '\t' --update-key a --update-mode allowinsert  --export-dir /path/dst/test_table/day=${day}

Step 2: 建 mysql 数据表

  • 连接到数据库
mysql -u name -p -h ip -P port test_db
  • 创建新表
mysql> create table if not exists test_table(
    a bigint,
    b bigint,
    primary key(a)
);

note: mysql表要和hive的字段一致

Step 3: 建 Coordinator

直接[Create],指定Workflow,指定运行时间即可。
最后点击[Submit]。

总结

学习了一番sql简单的语句,感觉收获不少。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容