urosstan-db commented on code in PR #53560:
URL: https://github.com/apache/spark/pull/53560#discussion_r2643131526
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala:
##########
@@ -360,6 +360,53 @@ class DataSourceV2Strategy(session: SparkSession) extends
Strategy with Predicat
throw SparkException.internalError("Unexpected table relation: " +
other)
}
+ case UpdateTable(relation, assignments, conditionOpt) =>
+ relation match {
+ case DataSourceV2ScanRelation(r, _, output, _, _) =>
+ val table = r.table
+ val condition = conditionOpt.getOrElse(TrueLiteral)
+ if (SubqueryExpression.hasSubquery(condition)) {
+ throw
QueryCompilationErrors.unsupportedUpdateByConditionWithSubqueryError(condition)
+ }
+ // Convert condition to predicates
+ val predicates = if (condition == TrueLiteral) {
+ Array.empty[Predicate]
+ } else {
+ DataSourceStrategy.normalizeExprs(Seq(condition), output)
+ .flatMap(splitConjunctivePredicates(_).map {
+ f => DataSourceV2Strategy.translateFilterV2(f).getOrElse(
+ throw
QueryCompilationErrors.cannotTranslateExpressionToSourceFilterError(f))
+ }).toArray
+ }
+
+ // Convert assignments to SupportsUpdateV2.Assignment
+ val updateAssignments = assignments.map { assignment =>
+ val colName = assignment.key match {
+ case attr: Attribute => attr.name
+ case other => other.sql
Review Comment:
What can be here except an attribute?
--
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]