I resolved this issue by creating a hierarchy data structure like this:
It allows an n-level relationship structure. If you’re using Athena as a datasource, you must base your Quicksight dataset on a query like the one below. It returns each row, it’s parent, and its fully qualified lineages. This query limits the depth of your structure to the number of Common Table Expressions (CTEs) that you manually script.
with L0 as (
select 0 level
,id
,name
,name fqn
,'' parentname
,'' parentfqn
,cast(h.id as varchar) || '.' fqid
,'' parentfqid
,h.class fqc
,h.owner
,h.owner fqo
,h.class
from hierarchy h where parent = 0
)
, L1 as (
Select length(L0.fqid) - length(REPLACE(L0.fqid, '.', '')) Level
,h.id
,h.name
,L0.fqn || '/' || h.name fqn
,L0.name parentname
,L0.fqn parentfqn
,L0.fqid || cast(h.id as varchar) || '.' fqid
,L0.fqid parentfqid
,L0.fqc || '/' || h.class fqc
,h.owner
,L0.fqo || '/' || h.owner fqo
,h.class
from hierarchy h
join L0 on L0.fqid = cast(h.parent as varchar) || '.'
)
, L2 as (
Select length(L1.fqid) - length(REPLACE(L1.fqid, '.', '')) Level
,h.id
,h.name
,L1.fqn || '/' || h.name fqn
,L1.name parentname
,L1.fqn parentfqn
,L1.fqid || cast(h.id as varchar) || '.' fqid
,L1.fqid parentfqid
,L1.fqc || '/' || h.class fqc
,h.owner
,L1.fqo || '/' || h.owner fqo
,h.class
from hierarchy h
join L1 on L1.fqid like '%.' || cast(h.parent as varchar) || '.'
)
,
Orgs as (
select * from L0
union select * from L1
union select * from L2
)
select *
, split_part(fqn,'/',1) L0,split_part(fqc,'/',1) L0Class, split_part(fqo,'/',1) L0Owner
, split_part(fqn,'/',2) L1, split_part(fqc,'/',2) L1Class, split_part(fqo,'/',2) L1Owner
, split_part(fqn,'/',3) L2, split_part(fqc,'/',3) L2Class, split_part(fqo,'/',3) L2Owner
from Orgs
I can tie other data into it using the ID value. It works in Quicksight for Pivot tables and Sankey Diagrams.