Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ trait LineageParser {
val exps = named.map {
case exp: Alias =>
val references =
if (exp.references.nonEmpty) exp.references
else {
if (exp.references.isEmpty || exp.child.isInstanceOf[ScalarSubquery]) {
val attrRefs = getExpressionSubqueryPlans(exp.child)
.map(extractColumnsLineage(_, ListMap[Attribute, AttributeSet]()))
.foldLeft(ListMap[Attribute, AttributeSet]())(mergeColumnsLineage).values
.foldLeft(AttributeSet.empty)(_ ++ _)
.map(attr => attr.withQualifier(attr.qualifier :+ SUBQUERY_COLUMN_IDENTIFIER))
AttributeSet(attrRefs)
} else {
exp.references
}
(
exp.toAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,18 @@ abstract class SparkSQLLineageParserHelperSuite extends KyuubiFunSuite
List(
("a", Set(s"$DEFAULT_CATALOG.default.table1.a")),
("b", Set(s"$DEFAULT_CATALOG.default.table1.b")))))

val sql12 =
"""
|select (select sum(a) from table0 where table1.b = table0.b) as aa, b from table1
|""".stripMargin
val ret12 = extractLineage(sql12)
assert(ret12 == Lineage(
List(s"$DEFAULT_CATALOG.default.table0", s"$DEFAULT_CATALOG.default.table1"),
List(),
List(
("aa", Set(s"$DEFAULT_CATALOG.default.table0.a")),
("b", Set(s"$DEFAULT_CATALOG.default.table1.b")))))
}
}

Expand Down
Loading