comphead commented on PR #4683:
URL:
https://github.com/apache/datafusion-comet/pull/4683#issuecomment-4759533810
> @comphead Spark uses this function to wrap string fields during
partitioning; it cannot be called via Spark SQL, but we need this function to
implement native partition writing.
I see, perhaps we can come up with unit test?
LLM suggests me something like
```
test("SPARK-XXXXX: empty partition values are written as null partitions") {
withTempDir { dir =>
val path = dir.getCanonicalPath
Seq(
(1, ""),
(2, "a"),
(3, null.asInstanceOf[String])
).toDF("id", "part")
.write
.partitionBy("part")
.parquet(path)
val fs = new Path(path).getFileSystem(spark.sessionState.newHadoopConf())
val partitions = fs.listStatus(new Path(path))
.filter(_.isDirectory)
.map(_.getPath.getName)
.sorted
assert(partitions.contains("part=a"))
// Empty string should not generate a dedicated partition directory.
assert(!partitions.contains("part="))
// Empty string and null should both map to the default partition.
assert(partitions.count(_.startsWith("part=__HIVE_DEFAULT_PARTITION__"))
== 1)
checkAnswer(
spark.read.parquet(path).groupBy("part").count(),
Row(null, 2) :: Row("a", 1) :: Nil
)
}
}
```
Without unit test it would be pretty complicated to ensure no regressions
happened
--
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]