NarekDW commented on code in PR #39723:
URL: https://github.com/apache/spark/pull/39723#discussion_r1088834285
##########
sql/core/src/test/scala/org/apache/spark/sql/errors/QueryCompilationErrorsSuite.scala:
##########
@@ -679,6 +681,68 @@ class QueryCompilationErrorsSuite
context = ExpectedContext("", "", 7, 13, "CAST(1)")
)
}
+
+ test("IDENTIFIER_TOO_MANY_NAME_PARTS: " +
+ "create temp view doesn't support identifiers consisting of more than 2
parts") {
+ checkError(
+ exception = intercept[ParseException] {
+ sql("CREATE TEMPORARY VIEW db_name.schema_name.view_name AS SELECT '1'
as test_column")
+ },
+ errorClass = "IDENTIFIER_TOO_MANY_NAME_PARTS",
+ parameters = Map(
+ "quoted" -> "db_name.schema_name.view_name",
+ "identifier" -> "TableIdentifier"
+ )
+ )
+ }
+
+ test("IDENTIFIER_TOO_MANY_NAME_PARTS: " +
+ "alter table doesn't support identifiers consisting of more than 2 parts")
{
+ val tableName: String = "t"
+ withTable(tableName) {
+ sql(
+ s"""
+ |CREATE TABLE $tableName (a STRING, b INT, c STRING, d STRING)
+ |USING parquet
+ |PARTITIONED BY (c, d)
+ |""".stripMargin)
+
+ checkError(
+ exception = intercept[AnalysisException] {
+ sql("ALTER TABLE t RENAME TO db_name.schema_name.new_table_name")
+ },
+ errorClass = "IDENTIFIER_TOO_MANY_NAME_PARTS",
+ parameters = Map(
+ "quoted" -> "db_name.schema_name.new_table_name",
+ "identifier" -> "TableIdentifier"
+ )
+ )
+ }
+ }
+}
+
+class QueryCompilationJDBCErrorsSuite extends JDBCV2Suite {
+
+ test("IDENTIFIER_TOO_MANY_NAME_PARTS: " +
+ "jdbc function doesn't support identifiers consisting of more than 2
parts") {
+ JdbcDialects.unregisterDialect(H2Dialect)
+ try {
+ JdbcDialects.registerDialect(testH2Dialect)
+ checkError(
+ exception = intercept[AnalysisException] {
+ sql("SELECT * FROM h2.test.people where
h2.db_name.schema_name.function_name()")
+ },
+ errorClass = "IDENTIFIER_TOO_MANY_NAME_PARTS",
+ parameters = Map(
+ "quoted" -> "db_name.schema_name.function_name",
+ "identifier" -> "FunctionIdentifier"
+ )
+ )
+ } finally {
+ JdbcDialects.unregisterDialect(testH2Dialect)
+ JdbcDialects.registerDialect(H2Dialect)
+ }
+ }
Review Comment:
These are all the sql queries I've found to reproduce
IDENTIFIER_TOO_MANY_NAME_PARTS error class.
Let me know if I missed some cases...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]