-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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-49739][SQL] Throw Custom error condition for invalid options in SaveIntoDataSourceCommand class #48188
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -2752,6 +2752,11 @@ | |
"message" : [ | ||
"A type of keys and values in `map()` must be string, but got <mapType>." | ||
] | ||
}, | ||
"NULL_VALUE" : { | ||
"message" : [ | ||
"Values of keys and values in `map()` must be string, but got null in value." | ||
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. Users can build values dynamically, and could be not clear which one is |
||
] | ||
} | ||
}, | ||
"sqlState" : "42K06" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ package org.apache.spark.sql.execution.datasources | |
|
||
import scala.util.control.NonFatal | ||
|
||
import org.apache.spark.SparkThrowable | ||
import org.apache.spark.{SparkIllegalArgumentException, SparkThrowable} | ||
import org.apache.spark.sql.{Dataset, Row, SaveMode, SparkSession} | ||
import org.apache.spark.sql.catalyst.plans.QueryPlan | ||
import org.apache.spark.sql.catalyst.plans.logical.{CTEInChildren, CTERelationDef, LogicalPlan, WithCTE} | ||
|
@@ -46,6 +46,10 @@ case class SaveIntoDataSourceCommand( | |
override def innerChildren: Seq[QueryPlan[_]] = Seq(query) | ||
|
||
override def run(sparkSession: SparkSession): Seq[Row] = { | ||
if (options.values.exists(_ == null)) { | ||
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. How about 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. No, the keys cannot be null since Map[String, String] can't accept null keys. |
||
throw new SparkIllegalArgumentException( | ||
errorClass = "INVALID_OPTIONS.NULL_VALUE") | ||
} | ||
var relation: BaseRelation = null | ||
|
||
try { | ||
|
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.
How about to re-use the existing error condition:
NULL_DATA_SOURCE_OPTION
?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 actually missed this condition, it makes more sense