Skip to content

Commit

Permalink
add test case for multiple relations and lateral
Browse files Browse the repository at this point in the history
  • Loading branch information
jiashenC committed Nov 16, 2024
1 parent 8fbd901 commit 6fdba10
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,40 @@ Project [pipeselect(1) AS x#x]
+- Relation spark_catalog.default.t[x#x,y#x] csv


-- !query
from t, other
|> select t.x + other.a as z
-- !query analysis
Project [pipeselect((x#x + a#x)) AS z#x]
+- Join Inner
:- SubqueryAlias spark_catalog.default.t
: +- Relation spark_catalog.default.t[x#x,y#x] csv
+- SubqueryAlias spark_catalog.default.other
+- Relation spark_catalog.default.other[a#x,b#x] json


-- !query
from t join other on (t.x = other.a)
|> select t.x + other.a as z
-- !query analysis
Project [pipeselect((x#x + a#x)) AS z#x]
+- Join Inner, (x#x = a#x)
:- SubqueryAlias spark_catalog.default.t
: +- Relation spark_catalog.default.t[x#x,y#x] csv
+- SubqueryAlias spark_catalog.default.other
+- Relation spark_catalog.default.other[a#x,b#x] json


-- !query
from t lateral view explode(array(100, 101)) as ly
|> select t.x + ly as z
-- !query analysis
Project [pipeselect((x#x + ly#x)) AS z#x]
+- Generate explode(array(100, 101)), false, as, [ly#x]
+- SubqueryAlias spark_catalog.default.t
+- Relation spark_catalog.default.t[x#x,y#x] csv


-- !query
table t
|> select 1 as x
Expand Down
12 changes: 12 additions & 0 deletions sql/core/src/test/resources/sql-tests/inputs/pipe-operators.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ table t;
from t
|> select 1 as x;

-- Selecting from multiple relations.
from t, other
|> select t.x + other.a as z;

-- Selecting from multiple relations with join.
from t join other on (t.x = other.a)
|> select t.x + other.a as z;

-- Selecting from lateral view.
from t lateral view explode(array(100, 101)) as ly
|> select t.x + ly as z;

-- Selecting a constant.
table t
|> select 1 as x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,42 @@ struct<x:int>
1


-- !query
from t, other
|> select t.x + other.a as z
-- !query schema
struct<z:int>
-- !query output
1
1
2
2
2
3


-- !query
from t join other on (t.x = other.a)
|> select t.x + other.a as z
-- !query schema
struct<z:int>
-- !query output
2
2


-- !query
from t lateral view explode(array(100, 101)) as ly
|> select t.x + ly as z
-- !query schema
struct<z:int>
-- !query output
100
101
101
102


-- !query
table t
|> select 1 as x
Expand Down

0 comments on commit 6fdba10

Please sign in to comment.