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
Add two cases with null.
  • Loading branch information
petermaxlee committed Aug 17, 2016
commit 47239020ac7008d8630a5c810df3db29a77795cf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ select * from values ("one", 1) as data;
select * from values ("one", 1) as data(a, b);
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 add a case for NULL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added


-- two rows
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: 3 rows

select * from values ("one", 1), ("two", 2) as data(a, b);
select * from values ("one", 1), ("two", 2), ("three", null) as data(a, b);

-- null type
select * from values ("one", null), ("two", null) as data(a, b);

-- int and long coercion
select * from values ("one", 1), ("two", 2L) as data(a, b);
Expand Down
64 changes: 37 additions & 27 deletions sql/core/src/test/resources/sql-tests/results/inline-table.sql.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 13
-- Number of queries: 14


-- !query 0
Expand Down Expand Up @@ -27,90 +27,100 @@ one 1


-- !query 3
select * from values ("one", 1), ("two", 2) as data(a, b)
select * from values ("one", 1), ("two", 2), ("three", null) as data(a, b)
-- !query 3 schema
struct<a:string,b:int>
-- !query 3 output
one 1
three NULL
two 2


-- !query 4
select * from values ("one", 1), ("two", 2L) as data(a, b)
select * from values ("one", null), ("two", null) as data(a, b)
-- !query 4 schema
struct<a:string,b:bigint>
struct<a:string,b:null>
-- !query 4 output
one 1
two 2
one NULL
two NULL


-- !query 5
select * from values ("one", 1 + 0), ("two", 1 + 3L) as data(a, b)
select * from values ("one", 1), ("two", 2L) as data(a, b)
-- !query 5 schema
struct<a:string,b:bigint>
-- !query 5 output
one 1
two 4
two 2


-- !query 6
select * from values ("one", array(0, 1)), ("two", array(2, 3)) as data(a, b)
select * from values ("one", 1 + 0), ("two", 1 + 3L) as data(a, b)
-- !query 6 schema
struct<a:string,b:array<int>>
struct<a:string,b:bigint>
-- !query 6 output
one [0,1]
two [2,3]
one 1
two 4


-- !query 7
select * from values ("one", 2.0), ("two", 3.0D) as data(a, b)
select * from values ("one", array(0, 1)), ("two", array(2, 3)) as data(a, b)
-- !query 7 schema
struct<a:string,b:double>
struct<a:string,b:array<int>>
-- !query 7 output
one 2.0
two 3.0
one [0,1]
two [2,3]


-- !query 8
select * from values ("one", 2.0), ("two") as data(a, b)
select * from values ("one", 2.0), ("two", 3.0D) as data(a, b)
-- !query 8 schema
struct<>
struct<a:string,b:double>
-- !query 8 output
org.apache.spark.sql.AnalysisException
expected 2 columns but found 1 columns in row 1; line 1 pos 14
one 2.0
two 3.0


-- !query 9
select * from values ("one", array(0, 1)), ("two", struct(1, 2)) as data(a, b)
select * from values ("one", 2.0), ("two") as data(a, b)
-- !query 9 schema
struct<>
-- !query 9 output
org.apache.spark.sql.AnalysisException
incompatible types found in column 1 for inline table; line 1 pos 14
expected 2 columns but found 1 columns in row 1; line 1 pos 14


-- !query 10
select * from values ("one"), ("two") as data(a, b)
select * from values ("one", array(0, 1)), ("two", struct(1, 2)) as data(a, b)
-- !query 10 schema
struct<>
-- !query 10 output
org.apache.spark.sql.AnalysisException
expected 2 columns but found 1 in first row; line 1 pos 14
incompatible types found in column 1 for inline table; line 1 pos 14


-- !query 11
select * from values ("one", random_not_exist_func(1)), ("two", 2) as data(a, b)
select * from values ("one"), ("two") as data(a, b)
-- !query 11 schema
struct<>
-- !query 11 output
org.apache.spark.sql.AnalysisException
Undefined function: 'random_not_exist_func'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 29
expected 2 columns but found 1 in first row; line 1 pos 14


-- !query 12
select * from values ("one", count(1)), ("two", 2) as data(a, b)
select * from values ("one", random_not_exist_func(1)), ("two", 2) as data(a, b)
-- !query 12 schema
struct<>
-- !query 12 output
org.apache.spark.sql.AnalysisException
Undefined function: 'random_not_exist_func'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 29


-- !query 13
select * from values ("one", count(1)), ("two", 2) as data(a, b)
-- !query 13 schema
struct<>
-- !query 13 output
org.apache.spark.sql.AnalysisException
cannot evaluate expression count(1) in inline table definition; line 1 pos 29