-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[HUDI-8823] Ban update from updating primary key and partition key #12587
Conversation
ed91af8
to
b247739
Compare
b247739
to
0c68d4f
Compare
...e/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/UpdateHoodieTableCommand.scala
Show resolved
Hide resolved
...e/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/UpdateHoodieTableCommand.scala
Outdated
Show resolved
Hide resolved
...e/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/UpdateHoodieTableCommand.scala
Outdated
Show resolved
Hide resolved
...e/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/UpdateHoodieTableCommand.scala
Outdated
Show resolved
Hide resolved
...e/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/UpdateHoodieTableCommand.scala
Outdated
Show resolved
Hide resolved
e2db61c
to
3cdd40d
Compare
3cdd40d
to
93feda8
Compare
assert(e1.getMessage.contains("Detected disallowed assignment clause in UPDATE statement for record key field `id`")) | ||
|
||
// Try to update partition column (should fail) | ||
val e2 = intercept[AnalysisException] { | ||
spark.sql(s"update $tableName set pt = '2022' where id = 1") | ||
} | ||
assert(e2.getMessage.contains("Detected update query with disallowed assignment clause for partition field `pt`")) | ||
assert(e2.getMessage.contains("Detected disallowed assignment clause in UPDATE statement for partition field `pt`")) |
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.
Add . Please remove the assignment clause to avoid the 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.
done
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.
LGTM
spark.sql(s"update $tableName set id = 2 where id = 1") | ||
} | ||
assert(e1.getMessage.contains(s"Detected disallowed assignment clause in UPDATE statement for record key field `id`" + | ||
s" for table `spark_catalog.default.$tableName`. Please remove the assignment clause to avoid the 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.
Does Spark add spark_catalog.
as the table name prefix? Could that be remove to avoid confusing users?
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 think it is good to stick to full qualifiers than just table name, since this causes 0 ambiguity. If given this fact we still think table name alone is better, I can fix
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.
Also for other loggings and user messages of SQL, we are consistently sticking to this format. The spark_catalog.
is the catalog name.
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.
Sg. Could you check the test failures on Spark 3.4?
4925fc8
to
1eacea9
Compare
f795ba1
to
39d7308
Compare
Change Logs
update will error out when it tries to change partition column /primary key column value.
Impact
guard update against unsupported use cases.
Risk level (write none, low medium or high below)
none
Documentation Update
Maybe we should update the update query doc on this behavior.
Contributor's checklist