Hive SQL 中 map, reduce 的数据血缘分析

Hive SQL 中的有些 SQL 语句和传统关系型数据库中使用的 SQL 语句在语法和功能上都有非常大的差异。在数据血缘分析中对这些 Hive SQL 特有的 SQL 语法的支持,是马哈鱼数据血缘关系分析工具和一般数据血缘分析工具的一个重要区别,对这些特殊 SQL 语法的支持,为企业的数据治理提供了完整的数据血缘,可以更好的提高数据质量,让企业的海量数据的在数据挖掘和智能分析中发挥更大的作用。

这里是一个典型的 Hive SQL,使用了 map, reduce。

  FROM (
    FROM pv_users
    MAP ( pv_users.userid, pv_users.date )
    USING 'map_script'
    AS c1, c2, c3
    DISTRIBUTE BY c2
    SORT BY c2, c1) map_output
  INSERT OVERWRITE TABLE pv_users_reduced
    REDUCE ( map_output.c1, map_output.c2, map_output.c3 )
    USING 'reduce_script'
    AS date, count;

该 Hive SQL语句把 pv_users.userid, pv_users.date 字段通过 map_script 脚本映射为 map_output c1, c2, c3 字段, 然后通过 reduce_script 脚本 reduce为 date, count 字段,插入到 pv_users_reduced 表。

我们可以梳理出如下的数据流:

pv_users.userid --> map_output c1
pv_users.userid --> map_output c2
pv_users.userid --> map_output c3
pv_users.date --> map_output c1
pv_users.date --> map_output c2
pv_users.date--> map_output c3

map_output c1 --> pv_users_reduced.date
map_output c1 --> pv_users_reduced.count
map_output c2 --> pv_users_reduced.date
map_output c2 --> pv_users_reduced.count
map_output c3 --> pv_users_reduced.date
map_output c3 --> pv_users_reduced.count

使用马哈鱼数据血缘分析工具,可以自动的分析出如下的数据血缘关系:

https://sqlflow.gudusoft.com

如果你正在使用 Hive SQL 来处理企业数据仓库中的大数据,进行数据的清洗、转换、计算等工作,那么,马哈鱼数据血缘分析工具可以为你自动梳理这些数据的血缘关系,告诉你数据的来龙去脉,极大的提高你的工作效率和数据治理水平。