-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-38131][SQL] Use error classes in user-facing exceptions only #35445
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
Changes from 2 commits
3ef0c5a
0982182
2ab7c5b
01372ff
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 |
|---|---|---|
|
|
@@ -3591,7 +3591,8 @@ class Analyzer(override val catalogManager: CatalogManager) | |
| case u @ UpCast(child, _, _) if !child.resolved => u | ||
|
|
||
| case UpCast(_, target, _) if target != DecimalType && !target.isInstanceOf[DataType] => | ||
| throw QueryCompilationErrors.unsupportedAbstractDataTypeForUpCastError(target) | ||
| throw new AnalysisException( | ||
|
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. For internal errors, can we throw |
||
| s"UpCast only supports DecimalType as AbstractDataType yet, but got: $target") | ||
|
|
||
| case UpCast(child, target, walkedTypePath) if target == DecimalType | ||
| && child.dataType.isInstanceOf[DecimalType] => | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,7 @@ case class CsvToStructs( | |
| assert(!rows.hasNext) | ||
| result | ||
| } else { | ||
| throw QueryExecutionErrors.rowFromCSVParserNotExpectedError | ||
| throw new IllegalStateException("Expected one row from CSV parser.") | ||
|
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 do believe this shouldn't happen. cc @HyukjinKwon
Member
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. lgtm |
||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,13 +17,9 @@ | |
|
|
||
| package org.apache.spark.sql.errors | ||
|
|
||
| import org.apache.spark.sql.{AnalysisException, Dataset, QueryTest} | ||
| import org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute | ||
| import org.apache.spark.sql.catalyst.expressions.{Alias, UpCast} | ||
| import org.apache.spark.sql.catalyst.plans.logical.Project | ||
| import org.apache.spark.sql.{AnalysisException, QueryTest} | ||
| import org.apache.spark.sql.functions.{grouping, grouping_id} | ||
| import org.apache.spark.sql.test.SharedSparkSession | ||
| import org.apache.spark.sql.types.NumericType | ||
|
|
||
| case class StringLongClass(a: String, b: Long) | ||
|
|
||
|
|
@@ -63,21 +59,6 @@ class QueryCompilationErrorsSuite extends QueryTest with SharedSparkSession { | |
| """.stripMargin.trim + " of the field in the target object") | ||
| } | ||
|
|
||
| test("UNSUPPORTED_FEATURE: UpCast only support DecimalType as AbstractDataType") { | ||
|
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. The test was added by #35366 recently while porting on error classes. So, it is safe to remove it. |
||
| val df = sql("select 1 as value") | ||
|
|
||
| val msg = intercept[AnalysisException] { | ||
| val plan = Project( | ||
| Seq(Alias(UpCast(UnresolvedAttribute("value"), NumericType), "value")()), | ||
| df.logicalPlan) | ||
|
|
||
| Dataset.ofRows(spark, plan) | ||
| }.message | ||
| assert(msg.matches("The feature is not supported: " + | ||
| "UpCast only support DecimalType as AbstractDataType yet," + | ||
| """ but got: org.apache.spark.sql.types.NumericType\$\@\w+""")) | ||
| } | ||
|
|
||
| test("UNSUPPORTED_GROUPING_EXPRESSION: filter with grouping/grouping_Id expression") { | ||
| val df = Seq( | ||
| (536361, "85123A", 2, 17850), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.