-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-38001][SQL] Replace the error classes related to unsupported features by UNSUPPORTED_FEATURE
#35302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-38001][SQL] Replace the error classes related to unsupported features by UNSUPPORTED_FEATURE
#35302
Changes from all commits
bcaa235
f026997
a903ad3
99c7913
32884da
9e67cab
fc7de5c
0a0d19f
27cdaab
0702ccc
a2af415
c72f9b2
d9c77fd
fedac2f
c0eee62
ffab56d
ff9a6a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.errors | ||
|
|
||
| import org.apache.spark.sql.{AnalysisException, QueryTest} | ||
| import org.apache.spark.sql.connector.{DatasourceV2SQLBase, FakeV2Provider} | ||
| import org.apache.spark.sql.test.SharedSparkSession | ||
|
|
||
| class QueryCompilationErrorsDSv2Suite | ||
| extends QueryTest | ||
| with SharedSparkSession | ||
| with DatasourceV2SQLBase { | ||
|
|
||
| test("UNSUPPORTED_FEATURE: IF PARTITION NOT EXISTS not supported by INSERT") { | ||
| val v2Format = classOf[FakeV2Provider].getName | ||
| val tbl = "testcat.ns1.ns2.tbl" | ||
|
|
||
| withTable(tbl) { | ||
| val view = "tmp_view" | ||
| val df = spark.createDataFrame(Seq((1L, "a"), (2L, "b"), (3L, "c"))).toDF("id", "data") | ||
| df.createOrReplaceTempView(view) | ||
| withTempView(view) { | ||
| sql(s"CREATE TABLE $tbl (id bigint, data string) USING $v2Format PARTITIONED BY (id)") | ||
|
|
||
| val e = intercept[AnalysisException] { | ||
| sql(s"INSERT OVERWRITE TABLE $tbl PARTITION (id = 1) IF NOT EXISTS SELECT * FROM $view") | ||
| } | ||
|
|
||
| checkAnswer(spark.table(tbl), spark.emptyDataFrame) | ||
| assert(e.getMessage === "The feature is not supported: " + | ||
| s"IF NOT EXISTS for the table '$tbl' by INSERT INTO.") | ||
| assert(e.getErrorClass === "UNSUPPORTED_FEATURE") | ||
| assert(e.getSqlState === "0A000") | ||
| } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ package org.apache.spark.sql.errors | |
|
|
||
| import org.apache.spark.{SparkException, SparkRuntimeException} | ||
| import org.apache.spark.sql.{DataFrame, QueryTest} | ||
| import org.apache.spark.sql.functions.{lit, lower, struct, sum} | ||
| import org.apache.spark.sql.test.SharedSparkSession | ||
|
|
||
| class QueryExecutionErrorsSuite extends QueryTest with SharedSparkSession { | ||
|
|
@@ -89,7 +90,7 @@ class QueryExecutionErrorsSuite extends QueryTest with SharedSparkSession { | |
| } | ||
| } | ||
|
|
||
| test("UNSUPPORTED_MODE: unsupported combinations of AES modes and padding") { | ||
| test("UNSUPPORTED_FEATURE: unsupported combinations of AES modes and padding") { | ||
| val key16 = "abcdefghijklmnop" | ||
| val key32 = "abcdefghijklmnop12345678ABCDEFGH" | ||
| val (df1, df2) = getAesInputs() | ||
|
|
@@ -112,4 +113,26 @@ class QueryExecutionErrorsSuite extends QueryTest with SharedSparkSession { | |
| checkUnsupportedMode(df2.selectExpr(s"aes_decrypt(value16, '$key16', 'GCM', 'PKCS')")) | ||
| checkUnsupportedMode(df2.selectExpr(s"aes_decrypt(value32, '$key32', 'ECB', 'None')")) | ||
| } | ||
|
|
||
| test("UNSUPPORTED_FEATURE: unsupported types (map and struct) in lit()") { | ||
| def checkUnsupportedTypeInLiteral(v: Any): Unit = { | ||
| val e1 = intercept[SparkRuntimeException] { lit(v) } | ||
| assert(e1.getErrorClass === "UNSUPPORTED_FEATURE") | ||
| assert(e1.getSqlState === "0A000") | ||
| assert(e1.getMessage.matches("""The feature is not supported: literal for '.+' of .+\.""")) | ||
| } | ||
| checkUnsupportedTypeInLiteral(Map("key1" -> 1, "key2" -> 2)) | ||
| checkUnsupportedTypeInLiteral(("mike", 29, 1.0)) | ||
|
|
||
| val e2 = intercept[SparkRuntimeException] { | ||
| trainingSales | ||
| .groupBy($"sales.year") | ||
| .pivot(struct(lower($"sales.course"), $"training")) | ||
| .agg(sum($"sales.earnings")) | ||
| .collect() | ||
| } | ||
| assert(e2.getMessage === "The feature is not supported: " + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH, this message is quite misleading, as the query does not create literals directly. We can improve it later.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opened the ticket SPARK-38097 to improve the error. |
||
| "literal for '[dotnet,Dummies]' of class " + | ||
| "org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema.") | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shall we add a
QueryCompilationErrorsSuiteand test this error?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InsertIntoSQLOnlyTestshas a test for the error already. BTW, the test fromInsertIntoSQLOnlyTestsruns as part of:@cloud-fan How about to create the
QueryCompilationErrorsSuiteBasetrait/abstract class and include it to those test suites?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the base test suites
QueryCompilationErrorsSuiteBase+SessionCatalogTestBaseand new test suites for compilation errors: