HyukjinKwon commented on a change in pull request #27110: [SPARK-30439][SQL]
Support non-nullable column in CREATE TABLE, ADD COLUMN and ALTER TABLE
URL: https://github.com/apache/spark/pull/27110#discussion_r364547107
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
##########
@@ -466,6 +466,13 @@ trait CheckAnalysis extends PredicateHelper {
s"${field.dataType.simpleString} cannot be cast to " +
s"${update.newDataType.simpleString}")
}
+ case update: UpdateColumnNullability =>
+ val field = findField("update", update.fieldNames)
+ val fieldName = update.fieldNames.quoted
+ if (!update.nullable && field.nullable) {
+ throw new AnalysisException(
+ s"Cannot change optional column to required: $fieldName")
Review comment:
nit: I know this already existed before but "optional" vs "required" are
confusing - sounds like this column itself can be missing optionally somehow.
It's really just "Cannot change non-nullable column to nullable column:
$fieldName"
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]