Skip to content
Snippets Groups Projects
Commit f37bb143 authored by Sunitha Kambhampati's avatar Sunitha Kambhampati Committed by Xiao Li
Browse files

[SPARK-19602][SQL][TESTS] Add tests for qualified column names

## What changes were proposed in this pull request?
- Add tests covering different scenarios with qualified column names
- Please see Section 2 in the design doc for the various test scenarios [here](https://issues.apache.org/jira/secure/attachment/12854681/Design_ColResolution_JIRA19602.pdf)
- As part of SPARK-19602, changes are made to support three part column name. In order to aid in the review and to reduce the diff, the test scenarios are separated out into this PR.

## How was this patch tested?
- This is a **test only** change. The individual test suites were run successfully.

Author: Sunitha Kambhampati <skambha@us.ibm.com>

Closes #17067 from skambha/colResolutionTests.
parent 93ae176e
No related branches found
No related tags found
No related merge requests found
-- Negative testcases for column resolution
CREATE DATABASE mydb1;
USE mydb1;
CREATE TABLE t1 USING parquet AS SELECT 1 AS i1;
CREATE DATABASE mydb2;
USE mydb2;
CREATE TABLE t1 USING parquet AS SELECT 20 AS i1;
-- Negative tests: column resolution scenarios with ambiguous cases in join queries
SET spark.sql.crossJoin.enabled = true;
USE mydb1;
SELECT i1 FROM t1, mydb1.t1;
SELECT t1.i1 FROM t1, mydb1.t1;
SELECT mydb1.t1.i1 FROM t1, mydb1.t1;
SELECT i1 FROM t1, mydb2.t1;
SELECT t1.i1 FROM t1, mydb2.t1;
USE mydb2;
SELECT i1 FROM t1, mydb1.t1;
SELECT t1.i1 FROM t1, mydb1.t1;
SELECT i1 FROM t1, mydb2.t1;
SELECT t1.i1 FROM t1, mydb2.t1;
SELECT db1.t1.i1 FROM t1, mydb2.t1;
SET spark.sql.crossJoin.enabled = false;
-- Negative tests
USE mydb1;
SELECT mydb1.t1 FROM t1;
SELECT t1.x.y.* FROM t1;
SELECT t1 FROM mydb1.t1;
USE mydb2;
SELECT mydb1.t1.i1 FROM t1;
-- reset
DROP DATABASE mydb1 CASCADE;
DROP DATABASE mydb2 CASCADE;
-- Tests for qualified column names for the view code-path
-- Test scenario with Temporary view
CREATE OR REPLACE TEMPORARY VIEW view1 AS SELECT 2 AS i1;
SELECT view1.* FROM view1;
SELECT * FROM view1;
SELECT view1.i1 FROM view1;
SELECT i1 FROM view1;
SELECT a.i1 FROM view1 AS a;
SELECT i1 FROM view1 AS a;
-- cleanup
DROP VIEW view1;
-- Test scenario with Global Temp view
CREATE OR REPLACE GLOBAL TEMPORARY VIEW view1 as SELECT 1 as i1;
SELECT * FROM global_temp.view1;
-- TODO: Support this scenario
SELECT global_temp.view1.* FROM global_temp.view1;
SELECT i1 FROM global_temp.view1;
-- TODO: Support this scenario
SELECT global_temp.view1.i1 FROM global_temp.view1;
SELECT view1.i1 FROM global_temp.view1;
SELECT a.i1 FROM global_temp.view1 AS a;
SELECT i1 FROM global_temp.view1 AS a;
-- cleanup
DROP VIEW global_temp.view1;
-- Tests covering different scenarios with qualified column names
-- Scenario: column resolution scenarios with datasource table
CREATE DATABASE mydb1;
USE mydb1;
CREATE TABLE t1 USING parquet AS SELECT 1 AS i1;
CREATE DATABASE mydb2;
USE mydb2;
CREATE TABLE t1 USING parquet AS SELECT 20 AS i1;
USE mydb1;
SELECT i1 FROM t1;
SELECT i1 FROM mydb1.t1;
SELECT t1.i1 FROM t1;
SELECT t1.i1 FROM mydb1.t1;
-- TODO: Support this scenario
SELECT mydb1.t1.i1 FROM t1;
-- TODO: Support this scenario
SELECT mydb1.t1.i1 FROM mydb1.t1;
USE mydb2;
SELECT i1 FROM t1;
SELECT i1 FROM mydb1.t1;
SELECT t1.i1 FROM t1;
SELECT t1.i1 FROM mydb1.t1;
-- TODO: Support this scenario
SELECT mydb1.t1.i1 FROM mydb1.t1;
-- Scenario: resolve fully qualified table name in star expansion
USE mydb1;
SELECT t1.* FROM t1;
SELECT mydb1.t1.* FROM mydb1.t1;
SELECT t1.* FROM mydb1.t1;
USE mydb2;
SELECT t1.* FROM t1;
-- TODO: Support this scenario
SELECT mydb1.t1.* FROM mydb1.t1;
SELECT t1.* FROM mydb1.t1;
SELECT a.* FROM mydb1.t1 AS a;
-- Scenario: resolve in case of subquery
USE mydb1;
CREATE TABLE t3 USING parquet AS SELECT * FROM VALUES (4,1), (3,1) AS t3(c1, c2);
CREATE TABLE t4 USING parquet AS SELECT * FROM VALUES (4,1), (2,1) AS t4(c2, c3);
SELECT * FROM t3 WHERE c1 IN (SELECT c2 FROM t4 WHERE t4.c3 = t3.c2);
-- TODO: Support this scenario
SELECT * FROM mydb1.t3 WHERE c1 IN
(SELECT mydb1.t4.c2 FROM mydb1.t4 WHERE mydb1.t4.c3 = mydb1.t3.c2);
-- Scenario: column resolution scenarios in join queries
SET spark.sql.crossJoin.enabled = true;
-- TODO: Support this scenario
SELECT mydb1.t1.i1 FROM t1, mydb2.t1;
-- TODO: Support this scenario
SELECT mydb1.t1.i1 FROM mydb1.t1, mydb2.t1;
USE mydb2;
-- TODO: Support this scenario
SELECT mydb1.t1.i1 FROM t1, mydb1.t1;
SET spark.sql.crossJoin.enabled = false;
-- Scenario: Table with struct column
USE mydb1;
CREATE TABLE t5(i1 INT, t5 STRUCT<i1:INT, i2:INT>) USING parquet;
INSERT INTO t5 VALUES(1, (2, 3));
SELECT t5.i1 FROM t5;
SELECT t5.t5.i1 FROM t5;
SELECT t5.t5.i1 FROM mydb1.t5;
SELECT t5.i1 FROM mydb1.t5;
SELECT t5.* FROM mydb1.t5;
SELECT t5.t5.* FROM mydb1.t5;
-- TODO: Support this scenario
SELECT mydb1.t5.t5.i1 FROM mydb1.t5;
-- TODO: Support this scenario
SELECT mydb1.t5.t5.i2 FROM mydb1.t5;
-- TODO: Support this scenario
SELECT mydb1.t5.* FROM mydb1.t5;
-- Cleanup and Reset
USE default;
DROP DATABASE mydb1 CASCADE;
DROP DATABASE mydb2 CASCADE;
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 28
-- !query 0
CREATE DATABASE mydb1
-- !query 0 schema
struct<>
-- !query 0 output
-- !query 1
USE mydb1
-- !query 1 schema
struct<>
-- !query 1 output
-- !query 2
CREATE TABLE t1 USING parquet AS SELECT 1 AS i1
-- !query 2 schema
struct<>
-- !query 2 output
-- !query 3
CREATE DATABASE mydb2
-- !query 3 schema
struct<>
-- !query 3 output
-- !query 4
USE mydb2
-- !query 4 schema
struct<>
-- !query 4 output
-- !query 5
CREATE TABLE t1 USING parquet AS SELECT 20 AS i1
-- !query 5 schema
struct<>
-- !query 5 output
-- !query 6
SET spark.sql.crossJoin.enabled = true
-- !query 6 schema
struct<key:string,value:string>
-- !query 6 output
spark.sql.crossJoin.enabled true
-- !query 7
USE mydb1
-- !query 7 schema
struct<>
-- !query 7 output
-- !query 8
SELECT i1 FROM t1, mydb1.t1
-- !query 8 schema
struct<>
-- !query 8 output
org.apache.spark.sql.AnalysisException
Reference 'i1' is ambiguous, could be: i1#x, i1#x.; line 1 pos 7
-- !query 9
SELECT t1.i1 FROM t1, mydb1.t1
-- !query 9 schema
struct<>
-- !query 9 output
org.apache.spark.sql.AnalysisException
Reference 't1.i1' is ambiguous, could be: i1#x, i1#x.; line 1 pos 7
-- !query 10
SELECT mydb1.t1.i1 FROM t1, mydb1.t1
-- !query 10 schema
struct<>
-- !query 10 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t1.i1`' given input columns: [i1, i1]; line 1 pos 7
-- !query 11
SELECT i1 FROM t1, mydb2.t1
-- !query 11 schema
struct<>
-- !query 11 output
org.apache.spark.sql.AnalysisException
Reference 'i1' is ambiguous, could be: i1#x, i1#x.; line 1 pos 7
-- !query 12
SELECT t1.i1 FROM t1, mydb2.t1
-- !query 12 schema
struct<>
-- !query 12 output
org.apache.spark.sql.AnalysisException
Reference 't1.i1' is ambiguous, could be: i1#x, i1#x.; line 1 pos 7
-- !query 13
USE mydb2
-- !query 13 schema
struct<>
-- !query 13 output
-- !query 14
SELECT i1 FROM t1, mydb1.t1
-- !query 14 schema
struct<>
-- !query 14 output
org.apache.spark.sql.AnalysisException
Reference 'i1' is ambiguous, could be: i1#x, i1#x.; line 1 pos 7
-- !query 15
SELECT t1.i1 FROM t1, mydb1.t1
-- !query 15 schema
struct<>
-- !query 15 output
org.apache.spark.sql.AnalysisException
Reference 't1.i1' is ambiguous, could be: i1#x, i1#x.; line 1 pos 7
-- !query 16
SELECT i1 FROM t1, mydb2.t1
-- !query 16 schema
struct<>
-- !query 16 output
org.apache.spark.sql.AnalysisException
Reference 'i1' is ambiguous, could be: i1#x, i1#x.; line 1 pos 7
-- !query 17
SELECT t1.i1 FROM t1, mydb2.t1
-- !query 17 schema
struct<>
-- !query 17 output
org.apache.spark.sql.AnalysisException
Reference 't1.i1' is ambiguous, could be: i1#x, i1#x.; line 1 pos 7
-- !query 18
SELECT db1.t1.i1 FROM t1, mydb2.t1
-- !query 18 schema
struct<>
-- !query 18 output
org.apache.spark.sql.AnalysisException
cannot resolve '`db1.t1.i1`' given input columns: [i1, i1]; line 1 pos 7
-- !query 19
SET spark.sql.crossJoin.enabled = false
-- !query 19 schema
struct<key:string,value:string>
-- !query 19 output
spark.sql.crossJoin.enabled false
-- !query 20
USE mydb1
-- !query 20 schema
struct<>
-- !query 20 output
-- !query 21
SELECT mydb1.t1 FROM t1
-- !query 21 schema
struct<>
-- !query 21 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t1`' given input columns: [i1]; line 1 pos 7
-- !query 22
SELECT t1.x.y.* FROM t1
-- !query 22 schema
struct<>
-- !query 22 output
org.apache.spark.sql.AnalysisException
cannot resolve 't1.x.y.*' give input columns 'i1';
-- !query 23
SELECT t1 FROM mydb1.t1
-- !query 23 schema
struct<>
-- !query 23 output
org.apache.spark.sql.AnalysisException
cannot resolve '`t1`' given input columns: [i1]; line 1 pos 7
-- !query 24
USE mydb2
-- !query 24 schema
struct<>
-- !query 24 output
-- !query 25
SELECT mydb1.t1.i1 FROM t1
-- !query 25 schema
struct<>
-- !query 25 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t1.i1`' given input columns: [i1]; line 1 pos 7
-- !query 26
DROP DATABASE mydb1 CASCADE
-- !query 26 schema
struct<>
-- !query 26 output
-- !query 27
DROP DATABASE mydb2 CASCADE
-- !query 27 schema
struct<>
-- !query 27 output
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 17
-- !query 0
CREATE OR REPLACE TEMPORARY VIEW view1 AS SELECT 2 AS i1
-- !query 0 schema
struct<>
-- !query 0 output
-- !query 1
SELECT view1.* FROM view1
-- !query 1 schema
struct<i1:int>
-- !query 1 output
2
-- !query 2
SELECT * FROM view1
-- !query 2 schema
struct<i1:int>
-- !query 2 output
2
-- !query 3
SELECT view1.i1 FROM view1
-- !query 3 schema
struct<i1:int>
-- !query 3 output
2
-- !query 4
SELECT i1 FROM view1
-- !query 4 schema
struct<i1:int>
-- !query 4 output
2
-- !query 5
SELECT a.i1 FROM view1 AS a
-- !query 5 schema
struct<i1:int>
-- !query 5 output
2
-- !query 6
SELECT i1 FROM view1 AS a
-- !query 6 schema
struct<i1:int>
-- !query 6 output
2
-- !query 7
DROP VIEW view1
-- !query 7 schema
struct<>
-- !query 7 output
-- !query 8
CREATE OR REPLACE GLOBAL TEMPORARY VIEW view1 as SELECT 1 as i1
-- !query 8 schema
struct<>
-- !query 8 output
-- !query 9
SELECT * FROM global_temp.view1
-- !query 9 schema
struct<i1:int>
-- !query 9 output
1
-- !query 10
SELECT global_temp.view1.* FROM global_temp.view1
-- !query 10 schema
struct<>
-- !query 10 output
org.apache.spark.sql.AnalysisException
cannot resolve 'global_temp.view1.*' give input columns 'i1';
-- !query 11
SELECT i1 FROM global_temp.view1
-- !query 11 schema
struct<i1:int>
-- !query 11 output
1
-- !query 12
SELECT global_temp.view1.i1 FROM global_temp.view1
-- !query 12 schema
struct<>
-- !query 12 output
org.apache.spark.sql.AnalysisException
cannot resolve '`global_temp.view1.i1`' given input columns: [i1]; line 1 pos 7
-- !query 13
SELECT view1.i1 FROM global_temp.view1
-- !query 13 schema
struct<i1:int>
-- !query 13 output
1
-- !query 14
SELECT a.i1 FROM global_temp.view1 AS a
-- !query 14 schema
struct<i1:int>
-- !query 14 output
1
-- !query 15
SELECT i1 FROM global_temp.view1 AS a
-- !query 15 schema
struct<i1:int>
-- !query 15 output
1
-- !query 16
DROP VIEW global_temp.view1
-- !query 16 schema
struct<>
-- !query 16 output
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 54
-- !query 0
CREATE DATABASE mydb1
-- !query 0 schema
struct<>
-- !query 0 output
-- !query 1
USE mydb1
-- !query 1 schema
struct<>
-- !query 1 output
-- !query 2
CREATE TABLE t1 USING parquet AS SELECT 1 AS i1
-- !query 2 schema
struct<>
-- !query 2 output
-- !query 3
CREATE DATABASE mydb2
-- !query 3 schema
struct<>
-- !query 3 output
-- !query 4
USE mydb2
-- !query 4 schema
struct<>
-- !query 4 output
-- !query 5
CREATE TABLE t1 USING parquet AS SELECT 20 AS i1
-- !query 5 schema
struct<>
-- !query 5 output
-- !query 6
USE mydb1
-- !query 6 schema
struct<>
-- !query 6 output
-- !query 7
SELECT i1 FROM t1
-- !query 7 schema
struct<i1:int>
-- !query 7 output
1
-- !query 8
SELECT i1 FROM mydb1.t1
-- !query 8 schema
struct<i1:int>
-- !query 8 output
1
-- !query 9
SELECT t1.i1 FROM t1
-- !query 9 schema
struct<i1:int>
-- !query 9 output
1
-- !query 10
SELECT t1.i1 FROM mydb1.t1
-- !query 10 schema
struct<i1:int>
-- !query 10 output
1
-- !query 11
SELECT mydb1.t1.i1 FROM t1
-- !query 11 schema
struct<>
-- !query 11 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t1.i1`' given input columns: [i1]; line 1 pos 7
-- !query 12
SELECT mydb1.t1.i1 FROM mydb1.t1
-- !query 12 schema
struct<>
-- !query 12 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t1.i1`' given input columns: [i1]; line 1 pos 7
-- !query 13
USE mydb2
-- !query 13 schema
struct<>
-- !query 13 output
-- !query 14
SELECT i1 FROM t1
-- !query 14 schema
struct<i1:int>
-- !query 14 output
20
-- !query 15
SELECT i1 FROM mydb1.t1
-- !query 15 schema
struct<i1:int>
-- !query 15 output
1
-- !query 16
SELECT t1.i1 FROM t1
-- !query 16 schema
struct<i1:int>
-- !query 16 output
20
-- !query 17
SELECT t1.i1 FROM mydb1.t1
-- !query 17 schema
struct<i1:int>
-- !query 17 output
1
-- !query 18
SELECT mydb1.t1.i1 FROM mydb1.t1
-- !query 18 schema
struct<>
-- !query 18 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t1.i1`' given input columns: [i1]; line 1 pos 7
-- !query 19
USE mydb1
-- !query 19 schema
struct<>
-- !query 19 output
-- !query 20
SELECT t1.* FROM t1
-- !query 20 schema
struct<i1:int>
-- !query 20 output
1
-- !query 21
SELECT mydb1.t1.* FROM mydb1.t1
-- !query 21 schema
struct<>
-- !query 21 output
org.apache.spark.sql.AnalysisException
cannot resolve 'mydb1.t1.*' give input columns 'i1';
-- !query 22
SELECT t1.* FROM mydb1.t1
-- !query 22 schema
struct<i1:int>
-- !query 22 output
1
-- !query 23
USE mydb2
-- !query 23 schema
struct<>
-- !query 23 output
-- !query 24
SELECT t1.* FROM t1
-- !query 24 schema
struct<i1:int>
-- !query 24 output
20
-- !query 25
SELECT mydb1.t1.* FROM mydb1.t1
-- !query 25 schema
struct<>
-- !query 25 output
org.apache.spark.sql.AnalysisException
cannot resolve 'mydb1.t1.*' give input columns 'i1';
-- !query 26
SELECT t1.* FROM mydb1.t1
-- !query 26 schema
struct<i1:int>
-- !query 26 output
1
-- !query 27
SELECT a.* FROM mydb1.t1 AS a
-- !query 27 schema
struct<i1:int>
-- !query 27 output
1
-- !query 28
USE mydb1
-- !query 28 schema
struct<>
-- !query 28 output
-- !query 29
CREATE TABLE t3 USING parquet AS SELECT * FROM VALUES (4,1), (3,1) AS t3(c1, c2)
-- !query 29 schema
struct<>
-- !query 29 output
-- !query 30
CREATE TABLE t4 USING parquet AS SELECT * FROM VALUES (4,1), (2,1) AS t4(c2, c3)
-- !query 30 schema
struct<>
-- !query 30 output
-- !query 31
SELECT * FROM t3 WHERE c1 IN (SELECT c2 FROM t4 WHERE t4.c3 = t3.c2)
-- !query 31 schema
struct<c1:int,c2:int>
-- !query 31 output
4 1
-- !query 32
SELECT * FROM mydb1.t3 WHERE c1 IN
(SELECT mydb1.t4.c2 FROM mydb1.t4 WHERE mydb1.t4.c3 = mydb1.t3.c2)
-- !query 32 schema
struct<>
-- !query 32 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t4.c3`' given input columns: [c2, c3]; line 2 pos 42
-- !query 33
SET spark.sql.crossJoin.enabled = true
-- !query 33 schema
struct<key:string,value:string>
-- !query 33 output
spark.sql.crossJoin.enabled true
-- !query 34
SELECT mydb1.t1.i1 FROM t1, mydb2.t1
-- !query 34 schema
struct<>
-- !query 34 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t1.i1`' given input columns: [i1, i1]; line 1 pos 7
-- !query 35
SELECT mydb1.t1.i1 FROM mydb1.t1, mydb2.t1
-- !query 35 schema
struct<>
-- !query 35 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t1.i1`' given input columns: [i1, i1]; line 1 pos 7
-- !query 36
USE mydb2
-- !query 36 schema
struct<>
-- !query 36 output
-- !query 37
SELECT mydb1.t1.i1 FROM t1, mydb1.t1
-- !query 37 schema
struct<>
-- !query 37 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t1.i1`' given input columns: [i1, i1]; line 1 pos 7
-- !query 38
SET spark.sql.crossJoin.enabled = false
-- !query 38 schema
struct<key:string,value:string>
-- !query 38 output
spark.sql.crossJoin.enabled false
-- !query 39
USE mydb1
-- !query 39 schema
struct<>
-- !query 39 output
-- !query 40
CREATE TABLE t5(i1 INT, t5 STRUCT<i1:INT, i2:INT>) USING parquet
-- !query 40 schema
struct<>
-- !query 40 output
-- !query 41
INSERT INTO t5 VALUES(1, (2, 3))
-- !query 41 schema
struct<>
-- !query 41 output
-- !query 42
SELECT t5.i1 FROM t5
-- !query 42 schema
struct<i1:int>
-- !query 42 output
1
-- !query 43
SELECT t5.t5.i1 FROM t5
-- !query 43 schema
struct<i1:int>
-- !query 43 output
2
-- !query 44
SELECT t5.t5.i1 FROM mydb1.t5
-- !query 44 schema
struct<i1:int>
-- !query 44 output
2
-- !query 45
SELECT t5.i1 FROM mydb1.t5
-- !query 45 schema
struct<i1:int>
-- !query 45 output
1
-- !query 46
SELECT t5.* FROM mydb1.t5
-- !query 46 schema
struct<i1:int,t5:struct<i1:int,i2:int>>
-- !query 46 output
1 {"i1":2,"i2":3}
-- !query 47
SELECT t5.t5.* FROM mydb1.t5
-- !query 47 schema
struct<i1:int,i2:int>
-- !query 47 output
2 3
-- !query 48
SELECT mydb1.t5.t5.i1 FROM mydb1.t5
-- !query 48 schema
struct<>
-- !query 48 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t5.t5.i1`' given input columns: [i1, t5]; line 1 pos 7
-- !query 49
SELECT mydb1.t5.t5.i2 FROM mydb1.t5
-- !query 49 schema
struct<>
-- !query 49 output
org.apache.spark.sql.AnalysisException
cannot resolve '`mydb1.t5.t5.i2`' given input columns: [i1, t5]; line 1 pos 7
-- !query 50
SELECT mydb1.t5.* FROM mydb1.t5
-- !query 50 schema
struct<>
-- !query 50 output
org.apache.spark.sql.AnalysisException
cannot resolve 'mydb1.t5.*' give input columns 'i1, t5';
-- !query 51
USE default
-- !query 51 schema
struct<>
-- !query 51 output
-- !query 52
DROP DATABASE mydb1 CASCADE
-- !query 52 schema
struct<>
-- !query 52 output
-- !query 53
DROP DATABASE mydb2 CASCADE
-- !query 53 schema
struct<>
-- !query 53 output
-- Automatically generated by SQLQueryTestSuite -- Automatically generated by SQLQueryTestSuite
-- Number of queries: 13 -- Number of queries: 7
-- !query 0 -- !query 0
...@@ -65,4 +65,3 @@ struct<a:int,tag:string> ...@@ -65,4 +65,3 @@ struct<a:int,tag:string>
1 a 1 a
1 b 1 b
1 b 1 b
...@@ -228,12 +228,12 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext { ...@@ -228,12 +228,12 @@ class SQLQueryTestSuite extends QueryTest with SharedSQLContext {
if (isSorted(df.queryExecution.analyzed)) (schema, answer) else (schema, answer.sorted) if (isSorted(df.queryExecution.analyzed)) (schema, answer) else (schema, answer.sorted)
} catch { } catch {
case a: AnalysisException if a.plan.nonEmpty => case a: AnalysisException =>
// Do not output the logical plan tree which contains expression IDs. // Do not output the logical plan tree which contains expression IDs.
// Also implement a crude way of masking expression IDs in the error message // Also implement a crude way of masking expression IDs in the error message
// with a generic pattern "###". // with a generic pattern "###".
(StructType(Seq.empty), val msg = if (a.plan.nonEmpty) a.getSimpleMessage else a.getMessage
Seq(a.getClass.getName, a.getSimpleMessage.replaceAll("#\\d+", "#x"))) (StructType(Seq.empty), Seq(a.getClass.getName, msg.replaceAll("#\\d+", "#x")))
case NonFatal(e) => case NonFatal(e) =>
// If there is an exception, put the exception class followed by the message. // If there is an exception, put the exception class followed by the message.
(StructType(Seq.empty), Seq(e.getClass.getName, e.getMessage)) (StructType(Seq.empty), Seq(e.getClass.getName, e.getMessage))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment