You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2019/08/16 08:25:18 UTC
[GitHub] [incubator-iceberg] jerryshao commented on a change in pull request
#374: Migrate spark table to iceberg table
jerryshao commented on a change in pull request #374: Migrate spark table to iceberg table
URL: https://github.com/apache/incubator-iceberg/pull/374#discussion_r314627097
##########
File path: spark/src/main/scala/org/apache/iceberg/spark/SparkTableUtil.scala
##########
@@ -297,5 +301,88 @@ object SparkTableUtil {
)
}
}
+
+ def buildManifest(table: Table,
+ sparkDataFiles: Seq[SparkDataFile],
+ partitionSpec: PartitionSpec): ManifestFile = {
+ val outputFile = table.io
+ .newOutputFile(FileFormat.AVRO.addExtension("/tmp/" + UUID.randomUUID.toString))
+ val writer = ManifestWriter.write(partitionSpec, outputFile)
+ try {
+ for (file <- sparkDataFiles) {
+ writer.add(file.toDataFile(partitionSpec))
+ }
+ } finally {
+ writer.close()
+ }
+
+ writer.toManifestFile
+ }
+
+ def partitionToMap(partition: String): Map[String, String] = {
+ val map = new mutable.HashMap[String, String]()
+ val list = partition.split("/")
+ list.foreach { str =>
+ val kv = str.split("=")
+ map.put(kv(0), kv(1))
+ }
+
+ map.toMap
Review comment:
```scala
partitions.split("/").map { s =>
val kv = s.split("=")
(kv(0), kv(1))
}.toMap
```
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org