2017-06-01 56 views
1

试想一下,我有这样的树:大厦层次使用星火

- One 
    - One one 
    - One two 
    - One two one 
    - One two two 
    - One two three 
     - One two three one 
    - One three 
    - One three one 
    - One three two 
    - One three three 
    - One four 
    - One five 

数据明智它很简单也只是一个父子关系:

+-------------------+---------------+ 
|  Child  | Parent  | 
+-------------------+---------------+ 
| One    |    | 
| One one   | One   | 
| One two   | One   | 
| One two one  | One two  | 
| One two two  | One two  | 
| One two three  | One two  | 
| One two three one | One two three | 
| One three   | One   | 
| One three one  | One three  | 
| One three two  | One three  | 
| One three three | One three  | 
| One four   | One   | 
| One five   | One   | 
+-------------------+---------------+ 

现在想什么,我做的是:

  • 我有两个项目的列表,让我们说One three threeOne two three one
  • 我想建造树父母的休息根级别

在RDBMS中,我会简单地写使用CTE和UNION ALL,但是我无法找到使用是否有可能在星火递归查询数据集或DataFrame,可能是由于缺乏Scala/Python知识。任何帮助,将不胜感激。

输出应该如下:

- One 
    - One two 
    - One two three 
     - One two three one 
    - One three 
    - One three three 

回答