Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Apply comments
  • Loading branch information
maropu committed May 10, 2017
commit 29281b1af00ced947173701378e9ad1b67e4924c
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,11 @@ class PlanParserSuite extends PlanTest {

test("SPARK-20311 range(N) as alias") {
assertEqual(
"select * from range(10) AS t",
"SELECT * FROM range(10) AS t",
SubqueryAlias("t", UnresolvedTableValuedFunction("range", Literal(10) :: Nil, Seq.empty))
.select(star()))
assertEqual(
"select * from range(7) AS t(a)",
"SELECT * FROM range(7) AS t(a)",
SubqueryAlias("t", UnresolvedTableValuedFunction("range", Literal(7) :: Nil, "a" :: Nil))
.select(star()))
}
Expand Down
3 changes: 3 additions & 0 deletions sql/core/src/test/resources/sql-tests/inputs/inline-table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ select * from values ("one", count(1)), ("two", 2) as data(a, b);

-- string to timestamp
select * from values (timestamp('1991-12-06 00:00:00.0'), array(timestamp('1991-12-06 01:00:00.0'), timestamp('1991-12-06 12:00:00.0'))) as data(a, b);

-- cross-join inline tables
SELECT * FROM VALUES ('one', 1), ('three', null) CROSS JOIN VALUES ('one', 1), ('three', null);
Copy link
Contributor

@cloud-fan cloud-fan May 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this expose the bug? If we treat CROSS as an alias, we still get the same result. how about we run EXPLAIN?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, ok

Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ select * from RaNgE(2);
EXPLAIN select * from RaNgE(2);

-- cross-join table valued functions
set spark.sql.crossJoin.enabled=true;
EXPLAIN EXTENDED select * from range(3) cross join range(3);
SET spark.sql.crossJoin.enabled=true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove this line? If we specify CROSS JOIN in the query, no need to set this parm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

EXPLAIN EXTENDED SELECT * FROM range(3) CROSS JOIN range(3);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 17
-- Number of queries: 18


-- !query 0
Expand Down Expand Up @@ -151,3 +151,14 @@ select * from values (timestamp('1991-12-06 00:00:00.0'), array(timestamp('1991-
struct<a:timestamp,b:array<timestamp>>
-- !query 16 output
1991-12-06 00:00:00 [1991-12-06 01:00:00.0,1991-12-06 12:00:00.0]


-- !query 17
SELECT * FROM VALUES ('one', 1), ('three', null) CROSS JOIN VALUES ('one', 1), ('three', null)
-- !query 17 schema
struct<col1:string,col2:int,col1:string,col2:int>
-- !query 17 output
one 1 one 1
one 1 three NULL
three NULL one 1
three NULL three NULL
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ struct<plan:string>


-- !query 9
set spark.sql.crossJoin.enabled=true
SET spark.sql.crossJoin.enabled=true
-- !query 9 schema
struct<key:string,value:string>
-- !query 9 output
spark.sql.crossJoin.enabled true


-- !query 10
EXPLAIN EXTENDED select * from range(3) cross join range(3)
EXPLAIN EXTENDED SELECT * FROM range(3) CROSS JOIN range(3)
-- !query 10 schema
struct<plan:string>
-- !query 10 output
Expand Down