dongjoon-hyun commented on a change in pull request #26929: [SPARK-30289][SQL]
DSv2's partitioning should not accept nested columns
URL: https://github.com/apache/spark/pull/26929#discussion_r359107616
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/CatalogV2Implicits.scala
##########
@@ -48,23 +48,27 @@ private[sql] object CatalogV2Implicits {
}
implicit class TransformHelper(transforms: Seq[Transform]) {
- def asPartitionColumns: Seq[String] = {
+ def validatePartitionColumns(): Unit = {
val (idTransforms, nonIdTransforms) =
transforms.partition(_.isInstanceOf[IdentityTransform])
if (nonIdTransforms.nonEmpty) {
throw new AnalysisException("Transforms cannot be converted to
partition columns: " +
- nonIdTransforms.map(_.describe).mkString(", "))
+ nonIdTransforms.map(_.describe).mkString(", "))
}
- idTransforms.map(_.asInstanceOf[IdentityTransform]).map(_.reference).map
{ ref =>
+
idTransforms.map(_.asInstanceOf[IdentityTransform]).map(_.reference).foreach {
ref =>
val parts = ref.fieldNames
if (parts.size > 1) {
throw new AnalysisException(s"Cannot partition by nested column:
$ref")
- } else {
- parts(0)
}
}
}
+
+ def asPartitionColumns: Seq[String] = {
+ validatePartitionColumns()
+
transforms.map(_.asInstanceOf[IdentityTransform]).map(_.reference).map(_.fieldNames.head)
Review comment:
Thank you for splitting the validation from the conversion.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]