Skip to content

Commit 0b32837

Browse files
committed
Add new golden file tests for analyzer edge cases
1 parent 06674ba commit 0b32837

File tree

60 files changed

+4151
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4151
-4
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
-- Automatically generated by SQLQueryTestSuite
2+
-- !query
3+
CREATE TABLE t1(col1 INT, col2 STRING)
4+
-- !query analysis
5+
CreateDataSourceTableCommand `spark_catalog`.`default`.`t1`, false
6+
7+
8+
-- !query
9+
CREATE TABLE t2(col1 STRUCT<a: STRING>, a STRING)
10+
-- !query analysis
11+
CreateDataSourceTableCommand `spark_catalog`.`default`.`t2`, false
12+
13+
14+
-- !query
15+
SELECT col1:a AS a, a:b AS b, a:c AS c FROM VALUES ('1') AS t(col1)
16+
-- !query analysis
17+
org.apache.spark.SparkException
18+
{
19+
"errorClass" : "INTERNAL_ERROR",
20+
"sqlState" : "XX000",
21+
"messageParameters" : {
22+
"message" : "Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'"
23+
}
24+
}
25+
26+
27+
-- !query
28+
SELECT LEN(LOWER('X')) AS a, 1 AS b, b AS c GROUP BY LOWER('X') ORDER BY LOWER('X')
29+
-- !query analysis
30+
Project [a#x, b#x, c#x]
31+
+- Sort [lower(X)#x ASC NULLS FIRST], true
32+
+- Project [len(lower(X)#x) AS a#x, b#x, b#x AS c#x, lower(X)#x AS lower(X)#x]
33+
+- Project [lower(X)#x, 1 AS b#x]
34+
+- Aggregate [lower(X)], [lower(X) AS lower(X)#x]
35+
+- OneRowRelation
36+
37+
38+
-- !query
39+
SELECT LEN(LOWER('X')) AS a, 1 AS b, b AS c GROUP BY LOWER('X') HAVING LOWER('X') = 'x'
40+
-- !query analysis
41+
Project [a#x, b#x, c#x]
42+
+- Filter (lower(X)#x = x)
43+
+- Project [len(lower(X)#x) AS a#x, b#x, b#x AS c#x, lower(X)#x AS lower(X)#x]
44+
+- Project [lower(X)#x, 1 AS b#x]
45+
+- Aggregate [lower(X)], [lower(X) AS lower(X)#x]
46+
+- OneRowRelation
47+
48+
49+
-- !query
50+
SELECT col1.field, field FROM VALUES(named_struct('field', 1))
51+
-- !query analysis
52+
Project [field#x, field#x]
53+
+- Project [col1#x, col1#x.field AS field#x]
54+
+- LocalRelation [col1#x]
55+
56+
57+
-- !query
58+
SELECT col1.field, field FROM VALUES(map('field', 1))
59+
-- !query analysis
60+
Project [field#x, field#x]
61+
+- Project [col1#x, col1#x[field] AS field#x]
62+
+- LocalRelation [col1#x]
63+
64+
65+
-- !query
66+
SELECT DISTINCT(col1.a:b.c AS out1, col1.a:b.d AS out2) FROM t2
67+
-- !query analysis
68+
org.apache.spark.SparkException
69+
{
70+
"errorClass" : "INTERNAL_ERROR",
71+
"sqlState" : "XX000",
72+
"messageParameters" : {
73+
"message" : "Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'"
74+
}
75+
}
76+
77+
78+
-- !query
79+
SELECT COUNT(col1) as alias, SUM(col1) + alias FROM t1 GROUP BY ALL
80+
-- !query analysis
81+
Project [alias#xL, (sum(col1)#xL + alias#xL) AS (sum(col1) + lateralAliasReference(alias))#xL]
82+
+- Project [count(col1)#xL, sum(col1)#xL, count(col1)#xL AS alias#xL]
83+
+- Aggregate [count(col1#x) AS count(col1)#xL, sum(col1#x) AS sum(col1)#xL]
84+
+- SubqueryAlias spark_catalog.default.t1
85+
+- Relation spark_catalog.default.t1[col1#x,col2#x] parquet
86+
87+
88+
-- !query
89+
SELECT COUNT(col1) as alias, SUM(col1) + alias, SUM(col1) + col1 FROM t1 GROUP BY ALL
90+
-- !query analysis
91+
org.apache.spark.sql.catalyst.ExtendedAnalysisException
92+
{
93+
"errorClass" : "UNRESOLVED_ALL_IN_GROUP_BY",
94+
"sqlState" : "42803",
95+
"queryContext" : [ {
96+
"objectType" : "",
97+
"objectName" : "",
98+
"startIndex" : 74,
99+
"stopIndex" : 85,
100+
"fragment" : "GROUP BY ALL"
101+
} ]
102+
}
103+
104+
105+
-- !query
106+
SELECT timestamp(col2:str) FROM t1 GROUP BY timestamp(col2:str)
107+
-- !query analysis
108+
org.apache.spark.SparkException
109+
{
110+
"errorClass" : "INTERNAL_ERROR",
111+
"sqlState" : "XX000",
112+
"messageParameters" : {
113+
"message" : "Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'"
114+
}
115+
}
116+
117+
118+
-- !query
119+
DROP TABLE t1
120+
-- !query analysis
121+
DropTable false, false
122+
+- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.t1
123+
124+
125+
-- !query
126+
DROP TABLE t2
127+
-- !query analysis
128+
DropTable false, false
129+
+- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.t2
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
-- Automatically generated by SQLQueryTestSuite
2+
-- !query
3+
CREATE TABLE t1(col1 INT)
4+
-- !query analysis
5+
CreateDataSourceTableCommand `spark_catalog`.`default`.`t1`, false
6+
7+
8+
-- !query
9+
CREATE TABLE t2(col1 STRUCT<a: STRING>, a STRING)
10+
-- !query analysis
11+
CreateDataSourceTableCommand `spark_catalog`.`default`.`t2`, false
12+
13+
14+
-- !query
15+
SELECT col1:a AS a, a:b AS b, a:c AS c FROM VALUES ('1') AS t(col1)
16+
-- !query analysis
17+
org.apache.spark.SparkException
18+
{
19+
"errorClass" : "INTERNAL_ERROR",
20+
"sqlState" : "XX000",
21+
"messageParameters" : {
22+
"message" : "Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'"
23+
}
24+
}
25+
26+
27+
-- !query
28+
SELECT LEN(LOWER('X')) AS a, 1 AS b, b AS c GROUP BY LOWER('X') ORDER BY LOWER('X')
29+
-- !query analysis
30+
Project [a#x, b#x, c#x]
31+
+- Sort [lower(X)#x ASC NULLS FIRST], true
32+
+- Project [len(lower(X)#x) AS a#x, b#x, b#x AS c#x, lower(X)#x AS lower(X)#x]
33+
+- Project [lower(X)#x, 1 AS b#x]
34+
+- Aggregate [lower(X)], [lower(X) AS lower(X)#x]
35+
+- OneRowRelation
36+
37+
38+
-- !query
39+
SELECT LEN(LOWER('X')) AS a, 1 AS b, b AS c GROUP BY LOWER('X') HAVING LOWER('X') = 'x'
40+
-- !query analysis
41+
Project [a#x, b#x, c#x]
42+
+- Filter (lower(X)#x = x)
43+
+- Project [len(lower(X)#x) AS a#x, b#x, b#x AS c#x, lower(X)#x AS lower(X)#x]
44+
+- Project [lower(X)#x, 1 AS b#x]
45+
+- Aggregate [lower(X)], [lower(X) AS lower(X)#x]
46+
+- OneRowRelation
47+
48+
49+
-- !query
50+
SELECT col1.field, field FROM VALUES(named_struct('field', 1))
51+
-- !query analysis
52+
Project [field#x, field#x]
53+
+- Project [col1#x, col1#x.field AS field#x]
54+
+- LocalRelation [col1#x]
55+
56+
57+
-- !query
58+
SELECT col1.field, field FROM VALUES(map('field', 1))
59+
-- !query analysis
60+
Project [field#x, field#x]
61+
+- Project [col1#x, col1#x[field] AS field#x]
62+
+- LocalRelation [col1#x]
63+
64+
65+
-- !query
66+
SELECT DISTINCT(col1.a:b.c AS out1, col1.a:b.d AS out2) FROM t2
67+
-- !query analysis
68+
org.apache.spark.SparkException
69+
{
70+
"errorClass" : "INTERNAL_ERROR",
71+
"sqlState" : "XX000",
72+
"messageParameters" : {
73+
"message" : "Cannot find main error class 'COLUMN_IS_NOT_VARIANT_TYPE'"
74+
}
75+
}
76+
77+
78+
-- !query
79+
SELECT COUNT(col1) as alias, SUM(col1) + alias FROM t1 GROUP BY ALL
80+
-- !query analysis
81+
Project [alias#xL, (sum(col1)#xL + alias#xL) AS (sum(col1) + lateralAliasReference(alias))#xL]
82+
+- Project [count(col1)#xL, sum(col1)#xL, count(col1)#xL AS alias#xL]
83+
+- Aggregate [count(col1#x) AS count(col1)#xL, sum(col1#x) AS sum(col1)#xL]
84+
+- SubqueryAlias spark_catalog.default.t1
85+
+- Relation spark_catalog.default.t1[col1#x] parquet
86+
87+
88+
-- !query
89+
SELECT COUNT(col1) as alias, SUM(col1) + alias, SUM(col1) + col1 FROM t1 GROUP BY ALL
90+
-- !query analysis
91+
org.apache.spark.sql.catalyst.ExtendedAnalysisException
92+
{
93+
"errorClass" : "UNRESOLVED_ALL_IN_GROUP_BY",
94+
"sqlState" : "42803",
95+
"queryContext" : [ {
96+
"objectType" : "",
97+
"objectName" : "",
98+
"startIndex" : 74,
99+
"stopIndex" : 85,
100+
"fragment" : "GROUP BY ALL"
101+
} ]
102+
}
103+
104+
105+
-- !query
106+
DROP TABLE t1
107+
-- !query analysis
108+
DropTable false, false
109+
+- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.t1
110+
111+
112+
-- !query
113+
DROP TABLE t2
114+
-- !query analysis
115+
DropTable false, false
116+
+- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.t2

sql/core/src/test/resources/sql-tests/analyzer-results/collations-basic.sql.out

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,14 @@ Project [try_validate_utf8(collate(utf8_binary#x, utf8_lcase_rtrim)) AS try_vali
11361136
+- Relation spark_catalog.default.t1[s#x,utf8_binary#x,utf8_lcase#x] parquet
11371137

11381138

1139+
-- !query
1140+
SELECT CASE WHEN utf8_lcase = 'XX' THEN 'XX' ELSE utf8_lcase END FROM t1
1141+
-- !query analysis
1142+
Project [CASE WHEN (utf8_lcase#x = XX) THEN XX ELSE utf8_lcase#x END AS CASE WHEN (utf8_lcase = 'XX' collate UTF8_LCASE) THEN 'XX' collate UTF8_LCASE ELSE utf8_lcase END#x]
1143+
+- SubqueryAlias spark_catalog.default.t1
1144+
+- Relation spark_catalog.default.t1[s#x,utf8_binary#x,utf8_lcase#x] parquet
1145+
1146+
11391147
-- !query
11401148
drop table t1
11411149
-- !query analysis

sql/core/src/test/resources/sql-tests/analyzer-results/cte.sql.out

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ CreateViewCommand `t3`, select * from t, false, false, LocalTempView, UNSUPPORTE
3030
+- LocalRelation [id#x]
3131

3232

33+
-- !query
34+
create table t4(col1 TIMESTAMP)
35+
-- !query analysis
36+
CreateDataSourceTableCommand `spark_catalog`.`default`.`t4`, false
37+
38+
3339
-- !query
3440
WITH s AS (SELECT 1 FROM s) SELECT * FROM s
3541
-- !query analysis
@@ -1031,6 +1037,94 @@ WithCTE
10311037
+- CTERelationRef xxxx, true, [1#x], false, false, 1
10321038

10331039

1040+
-- !query
1041+
SELECT * FROM (
1042+
WITH cte1 AS (SELECT * FROM t4) SELECT t4.col1 FROM t4 JOIN cte1 USING (col1)
1043+
)
1044+
-- !query analysis
1045+
Project [col1#x]
1046+
+- SubqueryAlias __auto_generated_subquery_name
1047+
+- WithCTE
1048+
:- CTERelationDef xxxx, false
1049+
: +- SubqueryAlias cte1
1050+
: +- Project [col1#x]
1051+
: +- SubqueryAlias spark_catalog.default.t4
1052+
: +- Relation spark_catalog.default.t4[col1#x] parquet
1053+
+- Project [col1#x]
1054+
+- Project [col1#x]
1055+
+- Join Inner, (col1#x = col1#x)
1056+
:- SubqueryAlias spark_catalog.default.t4
1057+
: +- Relation spark_catalog.default.t4[col1#x] parquet
1058+
+- SubqueryAlias cte1
1059+
+- CTERelationRef xxxx, true, [col1#x], false, false
1060+
1061+
1062+
-- !query
1063+
SELECT * FROM (
1064+
WITH cte1 AS (SELECT * FROM t4) SELECT cte1.col1 FROM t4 JOIN cte1 USING (col1)
1065+
)
1066+
-- !query analysis
1067+
Project [col1#x]
1068+
+- SubqueryAlias __auto_generated_subquery_name
1069+
+- WithCTE
1070+
:- CTERelationDef xxxx, false
1071+
: +- SubqueryAlias cte1
1072+
: +- Project [col1#x]
1073+
: +- SubqueryAlias spark_catalog.default.t4
1074+
: +- Relation spark_catalog.default.t4[col1#x] parquet
1075+
+- Project [col1#x]
1076+
+- Project [col1#x, col1#x]
1077+
+- Join Inner, (col1#x = col1#x)
1078+
:- SubqueryAlias spark_catalog.default.t4
1079+
: +- Relation spark_catalog.default.t4[col1#x] parquet
1080+
+- SubqueryAlias cte1
1081+
+- CTERelationRef xxxx, true, [col1#x], false, false
1082+
1083+
1084+
-- !query
1085+
SELECT * FROM (
1086+
WITH cte1 AS (SELECT * FROM t4) SELECT t4.col1 FROM cte1 JOIN t4 USING (col1)
1087+
)
1088+
-- !query analysis
1089+
Project [col1#x]
1090+
+- SubqueryAlias __auto_generated_subquery_name
1091+
+- WithCTE
1092+
:- CTERelationDef xxxx, false
1093+
: +- SubqueryAlias cte1
1094+
: +- Project [col1#x]
1095+
: +- SubqueryAlias spark_catalog.default.t4
1096+
: +- Relation spark_catalog.default.t4[col1#x] parquet
1097+
+- Project [col1#x]
1098+
+- Project [col1#x, col1#x]
1099+
+- Join Inner, (col1#x = col1#x)
1100+
:- SubqueryAlias cte1
1101+
: +- CTERelationRef xxxx, true, [col1#x], false, false
1102+
+- SubqueryAlias spark_catalog.default.t4
1103+
+- Relation spark_catalog.default.t4[col1#x] parquet
1104+
1105+
1106+
-- !query
1107+
SELECT * FROM (
1108+
WITH cte1 AS (SELECT * FROM t4) SELECT cte1.col1 FROM cte1 JOIN t4 USING (col1)
1109+
)
1110+
-- !query analysis
1111+
Project [col1#x]
1112+
+- SubqueryAlias __auto_generated_subquery_name
1113+
+- WithCTE
1114+
:- CTERelationDef xxxx, false
1115+
: +- SubqueryAlias cte1
1116+
: +- Project [col1#x]
1117+
: +- SubqueryAlias spark_catalog.default.t4
1118+
: +- Relation spark_catalog.default.t4[col1#x] parquet
1119+
+- Project [col1#x]
1120+
+- Project [col1#x]
1121+
+- Join Inner, (col1#x = col1#x)
1122+
:- SubqueryAlias cte1
1123+
: +- CTERelationRef xxxx, true, [col1#x], false, false
1124+
+- SubqueryAlias spark_catalog.default.t4
1125+
+- Relation spark_catalog.default.t4[col1#x] parquet
1126+
1127+
10341128
-- !query
10351129
DROP VIEW IF EXISTS t
10361130
-- !query analysis
@@ -1047,3 +1141,10 @@ DropTempViewCommand t2
10471141
DROP VIEW IF EXISTS t3
10481142
-- !query analysis
10491143
DropTempViewCommand t3
1144+
1145+
1146+
-- !query
1147+
DROP TABLE IF EXISTS t4
1148+
-- !query analysis
1149+
DropTable true, false
1150+
+- ResolvedIdentifier V2SessionCatalog(spark_catalog), default.t4

0 commit comments

Comments
 (0)