Skip to content
Closed
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 @@ -1627,7 +1627,15 @@ case class SubqueryAlias(

override def output: Seq[Attribute] = {
val qualifierList = identifier.qualifier :+ alias
child.output.map(_.withQualifier(qualifierList))
child.output.map { attr =>
// `SubqueryAlias` sets a new qualifier for its output columns. It doesn't make sense to still
// restrict the hidden columns of natural/using join to be accessed by qualified name only.
if (attr.qualifiedAccessOnly) {
attr.markAsAllowAnyAccess().withQualifier(qualifierList)
} else {
attr.withQualifier(qualifierList)
}
}
}

override def metadataOutput: Seq[Attribute] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,12 @@ package object util extends Logging {
.putBoolean(QUALIFIED_ACCESS_ONLY, true)
.build()
)

def markAsAllowAnyAccess(): Attribute = attr.withMetadata(
new MetadataBuilder()
.withMetadata(attr.metadata)
.remove(QUALIFIED_ACCESS_ONLY)
.build()
)
}
}
2 changes: 2 additions & 0 deletions sql/core/src/test/resources/sql-tests/inputs/natural-join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ SELECT *, nt2.k FROM nt1 natural join nt2;

SELECT nt1.k, nt2.k FROM nt1 natural join nt2;

SELECT k FROM (SELECT nt2.k FROM nt1 natural join nt2);

SELECT nt1.k, nt2.k FROM nt1 natural join nt2 where k = "one";

SELECT * FROM (SELECT * FROM nt1 natural join nt2);
Expand Down
8 changes: 8 additions & 0 deletions sql/core/src/test/resources/sql-tests/inputs/using-join.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ SELECT nt1.*, nt2.* FROM nt1 left outer join nt2 using (k);

SELECT nt1.k, nt2.k FROM nt1 left outer join nt2 using (k);

SELECT k FROM (SELECT nt2.k FROM nt1 left outer join nt2 using (k));

SELECT nt1.k, nt2.k FROM nt1 left outer join nt2 using (k) ORDER BY nt2.k;

SELECT k, nt1.k FROM nt1 left outer join nt2 using (k);
Expand All @@ -43,6 +45,8 @@ SELECT nt1.*, nt2.* FROM nt1 right outer join nt2 using (k);

SELECT nt1.k, nt2.k FROM nt1 right outer join nt2 using (k);

SELECT k FROM (SELECT nt1.k FROM nt1 right outer join nt2 using (k));

SELECT k, nt1.k FROM nt1 right outer join nt2 using (k);

SELECT k, nt2.k FROM nt1 right outer join nt2 using (k);
Expand All @@ -55,6 +59,8 @@ SELECT nt1.*, nt2.* FROM nt1 full outer join nt2 using (k);

SELECT nt1.k, nt2.k FROM nt1 full outer join nt2 using (k);

SELECT k FROM (SELECT nt2.k FROM nt1 full outer join nt2 using (k));

SELECT k, nt1.k FROM nt1 full outer join nt2 using (k);

SELECT k, nt2.k FROM nt1 full outer join nt2 using (k);
Expand All @@ -67,6 +73,8 @@ SELECT nt1.*, nt2.* FROM nt1 inner join nt2 using (k);

SELECT nt1.k, nt2.k FROM nt1 inner join nt2 using (k);

SELECT k FROM (SELECT nt2.k FROM nt1 inner join nt2 using (k));

SELECT k, nt1.k FROM nt1 inner join nt2 using (k);

SELECT k, nt2.k FROM nt1 inner join nt2 using (k);
10 changes: 10 additions & 0 deletions sql/core/src/test/resources/sql-tests/results/natural-join.sql.out
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ one one
two two


-- !query
SELECT k FROM (SELECT nt2.k FROM nt1 natural join nt2)
-- !query schema
struct<k:string>
-- !query output
one
one
two


-- !query
SELECT nt1.k, nt2.k FROM nt1 natural join nt2 where k = "one"
-- !query schema
Expand Down
44 changes: 44 additions & 0 deletions sql/core/src/test/resources/sql-tests/results/using-join.sql.out
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ three NULL
two two


-- !query
SELECT k FROM (SELECT nt2.k FROM nt1 left outer join nt2 using (k))
-- !query schema
struct<k:string>
-- !query output
NULL
one
one
two


-- !query
SELECT nt1.k, nt2.k FROM nt1 left outer join nt2 using (k) ORDER BY nt2.k
-- !query schema
Expand Down Expand Up @@ -190,6 +201,17 @@ one one
two two


-- !query
SELECT k FROM (SELECT nt1.k FROM nt1 right outer join nt2 using (k))
-- !query schema
struct<k:string>
-- !query output
NULL
one
one
two


-- !query
SELECT k, nt1.k FROM nt1 right outer join nt2 using (k)
-- !query schema
Expand Down Expand Up @@ -260,6 +282,18 @@ three NULL
two two


-- !query
SELECT k FROM (SELECT nt2.k FROM nt1 full outer join nt2 using (k))
-- !query schema
struct<k:string>
-- !query output
NULL
four
one
one
two


-- !query
SELECT k, nt1.k FROM nt1 full outer join nt2 using (k)
-- !query schema
Expand Down Expand Up @@ -326,6 +360,16 @@ one one
two two


-- !query
SELECT k FROM (SELECT nt2.k FROM nt1 inner join nt2 using (k))
-- !query schema
struct<k:string>
-- !query output
one
one
two


-- !query
SELECT k, nt1.k FROM nt1 inner join nt2 using (k)
-- !query schema
Expand Down