impala - 在 Hive 中为父母获取孩子和孙子
问题描述
我有一个层次结构 Hive 表,有两列,父和子。我需要获取与父记录关联的所有后代的列表。请注意,Hive/Imapala 不支持递归 SQL。
Source Table
+----+-----------+
| Parent | Child |
+----+-----------+
| a | b |
| b | c |
| c | d |
| d | e |
| e | f |
| f | x |
+----+-----------+
Expected Result:
+----+-----------+
| Parent | Child |
+----+-----------+
| a | b | // As b is the child of a, all the descendants of b
| a | c | // are also descendants of a.
| a | d |
| a | e |
| a | f |
| a | x |
| b | c | // As c is the child of b, all the descendants of c
| b | d | // are also descendants of b.
| b | e |
| b | f |
| b | x |
| c | d |
| c | e |
| c | f |
| c | x |
| d | e |
| d | f |
| d | x |
| e | f |
| e | x |
| f | x |
+----+-----------+
谢谢!
解决方案
推荐阅读
- angular - 使用带 queryParams 的角度路由器
- php - 如何在使用 Phpspreadsheet 下载 Excel 之前对其进行修改?
- json - 将 JSON 数据格式化为单行
- mysql - Why sql "column like 'pattern%'" doesn't use the index?
- performance - 为什么在展开的 ADD 循环中重新初始化寄存器会使它运行得更快,即使循环中有更多指令?
- unit-testing - 如何在 Quarkus 中覆盖一个单元测试的配置属性
- javascript - 如何通过 Javascript 显示选择应用程序对话框?
- java - 如何从java中的文本文件中打印出linkedList
- javascript - 使用烧瓶将 HTML(包括属性)从 python 发送到网页
- java - Junit MockMvc 使用 URL 中的路径变量执行 POST,返回 404 未找到