Skip to content

Commit 5673e1d

Browse files
committed
[SPARK-52545][SQL] Add quoted-identifier tests
1 parent d31408d commit 5673e1d

File tree

8 files changed

+1520
-4
lines changed

8 files changed

+1520
-4
lines changed

sql/core/src/test/resources/sql-tests/analyzer-results/double-quoted-identifiers-enabled.sql.out

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,215 @@ org.apache.spark.sql.AnalysisException
154154
}
155155

156156

157+
-- !query
158+
select 1 from "not_""exists"
159+
-- !query analysis
160+
org.apache.spark.sql.catalyst.ExtendedAnalysisException
161+
{
162+
"errorClass" : "TABLE_OR_VIEW_NOT_FOUND",
163+
"sqlState" : "42P01",
164+
"messageParameters" : {
165+
"relationName" : "`not_\"exists`"
166+
},
167+
"queryContext" : [ {
168+
"objectType" : "",
169+
"objectName" : "",
170+
"startIndex" : 15,
171+
"stopIndex" : 28,
172+
"fragment" : "\"not_\"\"exists\""
173+
} ]
174+
}
175+
176+
177+
-- !query
178+
USE SCHEMA "not_""exist"
179+
-- !query analysis
180+
org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
181+
{
182+
"errorClass" : "SCHEMA_NOT_FOUND",
183+
"sqlState" : "42704",
184+
"messageParameters" : {
185+
"schemaName" : "`spark_catalog`.`not_\"exist`"
186+
}
187+
}
188+
189+
190+
-- !query
191+
ALTER TABLE "not_""exist" ADD COLUMN not_exist int
192+
-- !query analysis
193+
org.apache.spark.sql.catalyst.ExtendedAnalysisException
194+
{
195+
"errorClass" : "TABLE_OR_VIEW_NOT_FOUND",
196+
"sqlState" : "42P01",
197+
"messageParameters" : {
198+
"relationName" : "`not_\"exist`"
199+
},
200+
"queryContext" : [ {
201+
"objectType" : "",
202+
"objectName" : "",
203+
"startIndex" : 13,
204+
"stopIndex" : 25,
205+
"fragment" : "\"not_\"\"exist\""
206+
} ]
207+
}
208+
209+
210+
-- !query
211+
ALTER TABLE not_exist ADD COLUMN "not_""exist" int
212+
-- !query analysis
213+
org.apache.spark.sql.catalyst.ExtendedAnalysisException
214+
{
215+
"errorClass" : "TABLE_OR_VIEW_NOT_FOUND",
216+
"sqlState" : "42P01",
217+
"messageParameters" : {
218+
"relationName" : "`not_exist`"
219+
},
220+
"queryContext" : [ {
221+
"objectType" : "",
222+
"objectName" : "",
223+
"startIndex" : 13,
224+
"stopIndex" : 21,
225+
"fragment" : "not_exist"
226+
} ]
227+
}
228+
229+
230+
-- !query
231+
SELECT 1 AS "not_""exist" FROM not_exist
232+
-- !query analysis
233+
org.apache.spark.sql.catalyst.ExtendedAnalysisException
234+
{
235+
"errorClass" : "TABLE_OR_VIEW_NOT_FOUND",
236+
"sqlState" : "42P01",
237+
"messageParameters" : {
238+
"relationName" : "`not_exist`"
239+
},
240+
"queryContext" : [ {
241+
"objectType" : "",
242+
"objectName" : "",
243+
"startIndex" : 32,
244+
"stopIndex" : 40,
245+
"fragment" : "not_exist"
246+
} ]
247+
}
248+
249+
250+
-- !query
251+
SELECT 1 FROM not_exist AS X("he""llo")
252+
-- !query analysis
253+
org.apache.spark.sql.catalyst.ExtendedAnalysisException
254+
{
255+
"errorClass" : "TABLE_OR_VIEW_NOT_FOUND",
256+
"sqlState" : "42P01",
257+
"messageParameters" : {
258+
"relationName" : "`not_exist`"
259+
},
260+
"queryContext" : [ {
261+
"objectType" : "",
262+
"objectName" : "",
263+
"startIndex" : 15,
264+
"stopIndex" : 23,
265+
"fragment" : "not_exist"
266+
} ]
267+
}
268+
269+
270+
-- !query
271+
SELECT "not_""exist"()
272+
-- !query analysis
273+
org.apache.spark.sql.AnalysisException
274+
{
275+
"errorClass" : "UNRESOLVED_ROUTINE",
276+
"sqlState" : "42883",
277+
"messageParameters" : {
278+
"routineName" : "`not_\"exist`",
279+
"searchPath" : "[`system`.`builtin`, `system`.`session`, `spark_catalog`.`default`]"
280+
},
281+
"queryContext" : [ {
282+
"objectType" : "",
283+
"objectName" : "",
284+
"startIndex" : 8,
285+
"stopIndex" : 22,
286+
"fragment" : "\"not_\"\"exist\"()"
287+
} ]
288+
}
289+
290+
291+
-- !query
292+
SELECT "not_""exist".not_exist()
293+
-- !query analysis
294+
org.apache.spark.sql.AnalysisException
295+
{
296+
"errorClass" : "UNRESOLVED_ROUTINE",
297+
"sqlState" : "42883",
298+
"messageParameters" : {
299+
"routineName" : "`not_\"exist`.`not_exist`",
300+
"searchPath" : "[`system`.`builtin`, `system`.`session`, `spark_catalog`.`default`]"
301+
},
302+
"queryContext" : [ {
303+
"objectType" : "",
304+
"objectName" : "",
305+
"startIndex" : 8,
306+
"stopIndex" : 32,
307+
"fragment" : "\"not_\"\"exist\".not_exist()"
308+
} ]
309+
}
310+
311+
312+
-- !query
313+
CREATE SCHEMA "my""schema"
314+
-- !query analysis
315+
org.apache.spark.sql.AnalysisException
316+
{
317+
"errorClass" : "INVALID_SCHEMA_OR_RELATION_NAME",
318+
"sqlState" : "42602",
319+
"messageParameters" : {
320+
"name" : "`my\"schema`"
321+
}
322+
}
323+
324+
325+
-- !query
326+
DROP SCHEMA "my""schema"
327+
-- !query analysis
328+
org.apache.spark.sql.catalyst.analysis.NoSuchNamespaceException
329+
{
330+
"errorClass" : "SCHEMA_NOT_FOUND",
331+
"sqlState" : "42704",
332+
"messageParameters" : {
333+
"schemaName" : "`spark_catalog`.`my\"schema`"
334+
}
335+
}
336+
337+
338+
-- !query
339+
CREATE TEMPORARY VIEW "v""iew"(c1) AS SELECT 1
340+
-- !query analysis
341+
CreateViewCommand `v"iew`, [(c1,None)], SELECT 1, false, false, LocalTempView, UNSUPPORTED, true
342+
+- Project [1 AS 1#x]
343+
+- OneRowRelation
344+
345+
346+
-- !query
347+
DROP VIEW "v""iew"
348+
-- !query analysis
349+
DropTempViewCommand `v"iew`
350+
351+
352+
-- !query
353+
CREATE TEMPORARY VIEW v("c""1") AS SELECT 1
354+
-- !query analysis
355+
CreateViewCommand `v`, [(c"1,None)], SELECT 1, false, false, LocalTempView, UNSUPPORTED, true
356+
+- Project [1 AS 1#x]
357+
+- OneRowRelation
358+
359+
360+
-- !query
361+
DROP VIEW v
362+
-- !query analysis
363+
DropTempViewCommand v
364+
365+
157366
-- !query
158367
SELECT 1 FROM `hello`
159368
-- !query analysis
@@ -329,6 +538,26 @@ org.apache.spark.sql.catalyst.ExtendedAnalysisException
329538
}
330539

331540

541+
-- !query
542+
SELECT "he""llo"
543+
-- !query analysis
544+
org.apache.spark.sql.catalyst.ExtendedAnalysisException
545+
{
546+
"errorClass" : "UNRESOLVED_COLUMN.WITHOUT_SUGGESTION",
547+
"sqlState" : "42703",
548+
"messageParameters" : {
549+
"objectName" : "`he\"llo`"
550+
},
551+
"queryContext" : [ {
552+
"objectType" : "",
553+
"objectName" : "",
554+
"startIndex" : 8,
555+
"stopIndex" : 16,
556+
"fragment" : "\"he\"\"llo\""
557+
} ]
558+
}
559+
560+
332561
-- !query
333562
CREATE TEMPORARY VIEW v(c1 COMMENT "hello") AS SELECT 1
334563
-- !query analysis
@@ -377,6 +606,13 @@ Project [hello AS hello#x]
377606
+- OneRowRelation
378607

379608

609+
-- !query
610+
SELECT 'he''llo'
611+
-- !query analysis
612+
Project [he'llo AS he'llo#x]
613+
+- OneRowRelation
614+
615+
380616
-- !query
381617
CREATE TEMPORARY VIEW v(c1 COMMENT 'hello') AS SELECT 1
382618
-- !query analysis
@@ -391,6 +627,20 @@ DROP VIEW v
391627
DropTempViewCommand v
392628

393629

630+
-- !query
631+
CREATE TEMPORARY VIEW v(c1 COMMENT 'he''llo') AS SELECT 1
632+
-- !query analysis
633+
CreateViewCommand `v`, [(c1,Some(he'llo))], SELECT 1, false, false, LocalTempView, UNSUPPORTED, true
634+
+- Project [1 AS 1#x]
635+
+- OneRowRelation
636+
637+
638+
-- !query
639+
DROP VIEW v
640+
-- !query analysis
641+
DropTempViewCommand v
642+
643+
394644
-- !query
395645
SELECT INTERVAL '1' YEAR
396646
-- !query analysis

0 commit comments

Comments
 (0)