You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "JingsongLi (via GitHub)" <gi...@apache.org> on 2023/07/03 02:55:04 UTC
[GitHub] [incubator-paimon] JingsongLi commented on a diff in pull request #1459: [spark] SQL: supports INSERT OVERWRITE syntax
JingsongLi commented on code in PR #1459:
URL: https://github.com/apache/incubator-paimon/pull/1459#discussion_r1250086712
##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/commands/PaimonCommand.scala:
##########
@@ -44,4 +47,50 @@ trait PaimonCommand {
throw new RuntimeException("Failed to deserialize CommitMessage's object", e)
}
}
+
+ /**
+ * For the 'INSERT OVERWRITE' semantics of SQL, Spark DataSourceV2 will call the `truncate`
+ * methods where the `AlwaysTrue` Filter is used.
+ */
+ def isTruncate(filter: Filter): Boolean = {
+ val filters = splitConjunctiveFilters(filter)
+ filters.length == 1 && filters.head.isInstanceOf[AlwaysTrue]
+ }
+
+ /**
+ * For the 'INSERT OVERWRITE T PARTITION (partitionVal, ...)' semantics of SQL, Spark will
+ * transform `partitionVal`s to EqualNullSafe Filters.
+ */
+ def convertFilterToMap(
+ filter: Filter,
+ partitionColumns: Seq[String],
+ resolver: Resolver): Map[String, String] = {
+ splitConjunctiveFilters(filter).map {
+ case EqualNullSafe(attribute, value) =>
+ if (isNestedFilterInValue(value)) {
+ throw new RuntimeException(
+ s"Not support the complex partition value in EqualNullSafe when run `INSERT OVERWRITE`.")
+ } else {
+ partitionColumns.find(resolver(_, attribute)).map((_, value.toString)).getOrElse {
Review Comment:
We should use `PredicateBuilder.convertJavaObject` to convert spark java object to our internal data structure.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org