cloud-fan commented on a change in pull request #29339:
URL: https://github.com/apache/spark/pull/29339#discussion_r510727968
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Implicits.scala
##########
@@ -62,4 +86,74 @@ object DataSourceV2Implicits {
new CaseInsensitiveStringMap(options.asJava)
}
}
+
+ implicit class PartitionSpecsHelper(partSpecs: Seq[PartitionSpec]) {
+ def resolved: Boolean =
partSpecs.forall(_.isInstanceOf[ResolvedPartitionSpec])
+
+ def asResolved(partSchema: StructType): Seq[ResolvedPartitionSpec] =
Review comment:
I'm not a big fan of implicit, and it's better to avoid it when
possible. For this particular case:
1. I would add a method in the rule `ResolvePartitionSpec` to resolve
partition spec.
2. In `ResolveSessionCatalog`, we don't need to check `if !specs.resolved`,
as it should be guaranteed. We can add a method there to turn `PartitionSpec`
to `(TablePartitionSpec, Option[String])`, with assertion that all the specs
should be `UnresolvedPartitionSpec`
3. In `DataSourceV2Strategy`, we don't need to check `if parts.resolved`, as
it should be guaranteed. We can simple add an assert there to make sure all
specs are `ResolvedPartitionSpec`
Thus, we can remove this implicit class without code duplication.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]