Skip to content

Commit

Permalink
Add test cases for UNNEST
Browse files Browse the repository at this point in the history
  • Loading branch information
takezoe committed Dec 19, 2023
1 parent 09287a3 commit 359a608
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,30 @@ class TypeResolverTest extends AirSpec with ResolverTestHelper {
ResolvedAttribute("value", DataType.LongType, Some("t"), None, None, None)
)
}

test("un3: resolve UNNEST array column without CROSS JOIN") {
val p = analyze("SELECT id, n FROM A, UNNEST (name) AS t (n)")
p.outputAttributes shouldMatch { case List(c1: Attribute, c2: Attribute) =>
c1.fullName shouldBe "id"
c2.fullName shouldBe "n"
}
}

test("un4: resolve UNNEST array column with the same output name") {
val p = analyze("SELECT id, t.name FROM A CROSS JOIN UNNEST (name) AS t (name)")

Check failure on line 980 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 2.12

TypeResolverTest.un4: resolve UNNEST array column with the same output name

[SyntaxError] line 1:45 name is ambiguous: - *name:string <- A.name - *name:?

Check failure on line 980 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 2.13

TypeResolverTest.un4: resolve UNNEST array column with the same output name

[SyntaxError] line 1:45 name is ambiguous: - *name:string <- A.name - *name:?

Check failure on line 980 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 2.13 + JDK21

TypeResolverTest.un4: resolve UNNEST array column with the same output name

[SyntaxError] line 1:45 name is ambiguous: - *name:string <- A.name - *name:?

Check failure on line 980 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 3

TypeResolverTest.un4: resolve UNNEST array column with the same output name

[SyntaxError] line 1:45 name is ambiguous: - *name:string <- A.name - *name:?

Check failure on line 980 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 3 + JDK21

TypeResolverTest.un4: resolve UNNEST array column with the same output name

[SyntaxError] line 1:45 name is ambiguous: - *name:string <- A.name - *name:?
p.outputAttributes shouldMatch { case List(c1: Attribute, c2: Attribute) =>
c1.fullName shouldBe "id"
c2.fullName shouldBe "t.name"
}
}

test("un5: resolve UNNEST array column with qualifier") {
val p = analyze("SELECT id, t.name FROM A CROSS JOIN UNNEST (A.name) AS t (name)")

Check failure on line 988 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 2.12

TypeResolverTest.un5: resolve UNNEST array column with qualifier

Found unresolved expressions in: [sql] SELECT id, t.name FROM A CROSS JOIN UNNEST (A.name) AS t (name) [plan] [Project]: (id:long, name:string, name:string) => (id:long, name:?) - *id:long <- A.id - UnresolvedAttribute(t.name) [CrossJoin]: (id:long, name:string, name:string) => (id:long, name:string, name:string) - NaturalJoin [TableScan] default.A: => (id:long, name:string) [AliasedRelation]: => (name:string) - ResolvedIdentifier(Id(t)) [Unnest]: => (name:string) - *A.name:string <- A.name [unresolved expressions] UnresolvedAttribute(t.name)

Check failure on line 988 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 2.13

TypeResolverTest.un5: resolve UNNEST array column with qualifier

Found unresolved expressions in: [sql] SELECT id, t.name FROM A CROSS JOIN UNNEST (A.name) AS t (name) [plan] [Project]: (id:long, name:string, name:string) => (id:long, name:?) - *id:long <- A.id - UnresolvedAttribute(t.name) [CrossJoin]: (id:long, name:string, name:string) => (id:long, name:string, name:string) - NaturalJoin [TableScan] default.A: => (id:long, name:string) [AliasedRelation]: => (name:string) - ResolvedIdentifier(Id(t)) [Unnest]: => (name:string) - *A.name:string <- A.name [unresolved expressions] UnresolvedAttribute(t.name)

Check failure on line 988 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 2.13 + JDK21

TypeResolverTest.un5: resolve UNNEST array column with qualifier

Found unresolved expressions in: [sql] SELECT id, t.name FROM A CROSS JOIN UNNEST (A.name) AS t (name) [plan] [Project]: (id:long, name:string, name:string) => (id:long, name:?) - *id:long <- A.id - UnresolvedAttribute(t.name) [CrossJoin]: (id:long, name:string, name:string) => (id:long, name:string, name:string) - NaturalJoin [TableScan] default.A: => (id:long, name:string) [AliasedRelation]: => (name:string) - ResolvedIdentifier(Id(t)) [Unnest]: => (name:string) - *A.name:string <- A.name [unresolved expressions] UnresolvedAttribute(t.name)

Check failure on line 988 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 3

TypeResolverTest.un5: resolve UNNEST array column with qualifier

Found unresolved expressions in: [sql] SELECT id, t.name FROM A CROSS JOIN UNNEST (A.name) AS t (name) [plan] [Project]: (id:long, name:string, name:string) => (id:long, name:?) - *id:long <- A.id - UnresolvedAttribute(t.name) [CrossJoin]: (id:long, name:string, name:string) => (id:long, name:string, name:string) - NaturalJoin [TableScan] default.A: => (id:long, name:string) [AliasedRelation]: => (name:string) - ResolvedIdentifier(Id(t)) [Unnest]: => (name:string) - *A.name:string <- A.name [unresolved expressions] UnresolvedAttribute(t.name)

Check failure on line 988 in airframe-sql/src/test/scala/wvlet/airframe/sql/analyzer/TypeResolverTest.scala

View workflow job for this annotation

GitHub Actions / Scala 3 + JDK21

TypeResolverTest.un5: resolve UNNEST array column with qualifier

Found unresolved expressions in: [sql] SELECT id, t.name FROM A CROSS JOIN UNNEST (A.name) AS t (name) [plan] [Project]: (id:long, name:string, name:string) => (id:long, name:?) - *id:long <- A.id - UnresolvedAttribute(t.name) [CrossJoin]: (id:long, name:string, name:string) => (id:long, name:string, name:string) - NaturalJoin [TableScan] default.A: => (id:long, name:string) [AliasedRelation]: => (name:string) - ResolvedIdentifier(Id(t)) [Unnest]: => (name:string) - *A.name:string <- A.name [unresolved expressions] UnresolvedAttribute(t.name)
p.outputAttributes shouldMatch { case List(c1: Attribute, c2: Attribute) =>
c1.fullName shouldBe "id"
c2.fullName shouldBe "t.name"
}
}
}

test("resolve select from values") {
Expand Down

0 comments on commit 359a608

Please sign in to comment.