anuragmantri commented on code in PR #56792:
URL: https://github.com/apache/spark/pull/56792#discussion_r3484823156
##########
sql/api/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4:
##########
@@ -739,8 +739,8 @@ resource
dmlStatementNoWith
: insertInto (query | LEFT_PAREN query RIGHT_PAREN queryAlias=tableAlias)
#singleInsertQuery
| fromClause multiInsertQueryBody+
#multiInsertQuery
- | DELETE FROM identifierReference tableAlias whereClause?
#deleteFromTable
- | UPDATE identifierReference tableAlias setClause whereClause?
#updateTable
+ | DELETE FROM identifierReference optionsClause? tableAlias whereClause?
#deleteFromTable
+ | UPDATE identifierReference optionsClause? tableAlias setClause
whereClause? #updateTable
| MERGE (WITH SCHEMA EVOLUTION)? INTO target=identifierReference
targetAlias=tableAlias
Review Comment:
I intentionally did not add MERGE as the semantics are a bit different since
MERGE statements have source and target relations, I'm still thinking about how
options would look like there. I can file a separate JIRA and PR for MERGE
later.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/RewriteDeleteFromTable.scala:
##########
@@ -45,7 +44,7 @@ object RewriteDeleteFromTable extends RewriteRowLevelCommand {
d
case r @ ExtractV2Table(t: SupportsRowLevelOperations) =>
Review Comment:
Great catch. I looked at those paths. The options are indeed not being
passed all the way. Fixing this requires DSv2 API changes something like this
with default methods.
```java
// SupportsDeleteV2
default void deleteWhere(Predicate[] predicates, CaseInsensitiveStringMap
options) {
deleteWhere(predicates); // default ignores options → fully
back-compatible
}
// TruncatableTable
default boolean truncateTable(CaseInsensitiveStringMap options) {
return truncateTable();
}
```
I can make this change in this same PR or can do a follow up if DSv2 changes
need separate PRs. Let me know what do you think is the best way forward.
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/DDLParserSuite.scala:
##########
@@ -2211,6 +2212,32 @@ class DDLParserSuite extends AnalysisTest {
stop = 56))
}
+ test("delete from table: with options") {
Review Comment:
For sure. I took a look and looks like INSERT docs are also not updated. I
will create a follow up JIRA to update all options related DMLS at once.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]